Php code used to obtain the absolute path of the current file
- $ Basedir = dirname (_ FILE __);
- Echo $ basedir;
- // An absolute path of the file will be printed on the page!
- ?>
-
You can use
- Define ('root', dirname (_ FILE __));
- Require_once ROOT. '/config/conf_mysql.php ';
Import file Several common PHP"Magic constant"Name specifies the current row number in the _ LINE _ file. The complete path and FILE name of The _ FILE. If it is used in a include file, the include file name is returned. Starting from PHP 4.0.2, __file _ always contains an absolute path, while earlier versions sometimes contain a relative path. _ FUNCTION name (new in PHP 4.3.0 ). Starting from PHP 5, this constant returns the name (case sensitive) when the function is defined ). In PHP 4, the value is always lowercase letters. _ CLASS name (new in PHP 4.3.0 ). Starting from PHP 5, this constant returns the name (case sensitive) when the class is defined ). In PHP 4, the value is always lowercase letters. _ METHOD _ class METHOD name (new PHP 5.0.0 ). Returns the name (case sensitive) when the method is defined ). Please master the above and use more programming skills. |