Q:

PHP program to print the line number using __LINE__ magic constant

belongs to collection: PHP Classes & Objects Programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP Classes & Objects Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
PHP program to print the full path of the current ... >>
<< PHP program to check a constant is defined or not...