PHP has many functions that can be used to directly debug, view variables, objects, arrays, Everything..., they are called magic variables:
Magic variable | meaning | Comment |
---|---|---|
__ LINE__ | The current line number in the file. | It records the line number of the line where the currently executed code is located. Usage: echo'__ LINE__' |
__ FILE__ | The full path and file name of the file. | If used in an included file, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path (if it is a symbolic link, it is the resolved absolute path), and versions before this sometimes include a relative path. |
__ TO YOU__ | The directory where the file is located. | If used in an included file, the directory where the included file is located is returned. It is equivalent to dirname(__ FILE__). Unless it is the root directory, the name in the directory does not include the trailing slash. (New in PHP 5.3.0) |
__ FUNCTION__ | Function name (added in PHP 4.3.0). | Since PHP 5, this constant returns the name of the function when it was defined (case sensitive). In PHP 4 the value is always lowercase. |
__ CLASS__ | The name of the class (added in PHP 4.3.0). | Since PHP 5, this constant returns the name of the class when it was defined (case sensitive). In PHP 4 the value is always lowercase. |
__ METHOD__ | The method name of the class (added in PHP 5.0.0). | Returns the name of the method when it was defined (case sensitive). |
__NAMESPACE __ | The name of the current namespace (case sensitive). | This constant is defined at compile time (added in PHP 5.3.0) |