Magic constants
by raja[ Edit ] 2007-09-28 15:48:11
There are 5 magic constants(predefined) in php which will give the values depending on the page or place where they are used.
1. __LINE__ : The current line number of the file.
2. __FILE__ : The full path and filename of the file.
3. __FUNCTION__ : The function name.
4. __CLASS__ : The class name.
5. __METHOD__ : The class method name.
These are case-insensitive.
For example,
<?php
//sample
$x=__file__;
echo __line__;
echo "<br>$x";
?>
the O/P of the above was, 4 e:\s.php
Similarly you can use the other constants with classes and functions.
Thanks