Home > Article > Backend Development > PHP implementation code to obtain the absolute path of the current file
Can be used later
Import files Several commonly used PHP "Magic constants" Name Description __LINE__ The current line number in the file. __FILE__ The full path and file name of the file. If used in an include file, returns the include file name. As of PHP 4.0.2, __FILE__ always contains an absolute path, while versions before that sometimes contained a relative path. __FUNCTION__ function name (new in PHP 4.3.0). Since PHP 5 this constant returns the name of the function as it was defined (case sensitive). In PHP 4 this value is always lowercase. __CLASS__ The name of the class (new 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 this value is always lowercase. __METHOD__ The method name of the class (newly added in PHP 5.0.0). Returns the name of the method when it was defined (case-sensitive). Please have a firm grasp of the above and use them more in programming skills. |