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 [Last updated : March 13, 2023]

__LINE__ Magic Constant Example

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

PHP code to demonstrate the example of __LINE__ magic constant

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.

PHP Class & Object Programs »



Related Programs




Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.