Magic Constants in PHP

Magic constants are basically used for debugging purpose in php and the sintax is like __FILE__ , __LINE__, etc.There are around 8 Magic Constants in PHP , that are:-





1) __LINE__ Constant displays the current line number.
2) __FILE__ Displays the file name with its path.
3) __DIR__ This will print full path to directory in which your file is places.
4) __FUNCTION__ Displays function name. It was added in PHP 4.3.0.
5) __CLASS__ Will returns the class name.
6) __TRAIT__ It will return the traits name in which this is used.
7) __METHOD__ This will return name of the class method name and it will return as it is.
8) __NAMESPACE__ Which returns the current namespace name.


Related posts:

Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us