PHP Magic Constants

In PHP, the constants who change themselves depending upon the way they are used are known as Magic Constants. There are nine such constants in PHP. Unlike other constants magical constants are resolved at compile time. These are case-insensitive constants. Magical constants are as listed below:

NameDescription
__LINE__Current line number of the file.
__FILE__The full path and filename of the file. If it is used inside an include, it will return the included file.
__DIR__The directory of the file. If it is used inside an include, it will return the directory of the included file.
__FUNCTION__The function name.
__CLASS__The class name. It also includes the namespace in which the class was declared.
__TRAIT__The trait name. It also includes the namespace in which the trait was declared.
__METHOD__The method name.
__NAMESPACE__Name of the current namespace.
ClassName :: classFully qualified class name.