solvit.io

List of magic constants defined by PHP

These magic constants return different values depending on where they are used:

All PHP versions
Constant Description
__LINE__ The line number of the file being executed (mostly used to display the line number when an error happened)
__FILE__ Absolute path and filename of the file being executed (symbolic links are resolved)
__FUNCTION__ The name of the function being executed (or null if no function is being executed)
__CLASS__ The FQCN of the class being executed (it includes the full namespace (if any) and the class name)
__METHOD__ The name of the class method being executed (or null if no method is being executed)
PHP 5.3.0 and higher
Constant Description
__DIR__ The directory where the file being executed is stored without the trailing slash (equivalent to dirname(__FILE__))
__NAMESPACE__ The namespace where the code currently being executed is defined
PHP 5.4.0 and higher
Constant Description
__TRAIT__ The FQCN of the trait being executed (it includes the full namespace (if any) and the trait name)
Find more solutions about: ,