PHP program to print the line number using __LINE__ magic constant

Here, we are going to learn how to print the line number using __LINE__ magic constant in PHP?
Submitted by Nidhi, on November 11, 2020

Here, we print the line number using the __LINE__ magic constant on the webpage.

Program/Source Code:

The source code to print line number using __LINE__ magic constant is given below. The given program is compiled and executed successfully.

<?php
//PHP program to print line number
//using __LINE__ constant.

print ("Line : " . __LINE__ . "<br>");
print ("Line : " . __LINE__ . "<br>");
print ("Line : " . __LINE__ . "<br>");
print ("Line : " . __LINE__ . "<br>");
?>

Output:

Line : 3
Line : 4
Line : 5
Line : 6

Explanation:

In the above program, we used magic constant __LINE__ 4 times that will print line numbers on the webpage.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.