Inspiration For Creative Minds
Home » Labs » Magic Constants in PHP  

Filed under Labs

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:-

————————————————–

__LINE__
__FILE__
__DIR__
__FUNCTION__
__CLASS__
__TRAIT__
__METHOD__
__NAMESPACE__

————————————————–

Explanation

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.

It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook
Labs

Posts you may like: