Magic Constants

suggest change

Remarks

Magic constants are distinguished by their __CONSTANTNAME__ form.

Eight magic constants change based on where they are used. __LINE__ is the line it appears on.

These constants are case-insensitive:

Name Description
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned.
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory.
__FUNCTION__ The current function name.
__CLASS__ The class name. The class name includes the namespace it was declared in (for example Foo\Bar). When used in a trait method, __CLASS__ is the name of the class the trait is used in.
__TRAIT__ The trait name. The trait name includes the namespace it was declared in (for example Foo\Bar).
__METHOD__ The class method name.
__NAMESPACE__ The name of the current namespace.

The most common use of these constants is debugging and logging.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents