PHP dirname (_ file __)

Source: Internet
Author: User

The path of _ file _ is the file where the current code is located.

 

Dirname (_ file _); the directory name at the top of the file is obtained.

Dirname (_ file _); the directory name of the file's layer is obtained.

"../" Is suitable for a simple file containing another file. Most dirname (_ file _) is suitable for multiple layers, more complex file inclusion, and easier maintenance. If only the. php file contains the B. php file, you can directly use the dirname (_ file _) or "../" of the include file. Generally, no error occurs. But usually a contains B files, and C. if PHP contains file a, use ".. /", it will cause the path error when C contains a and then loads B files, and when dirname (_ file _) is used, when C contains a, It maps the path relationship between C and A with dirname (_ file,
When file a contains file B, the corresponding directory relationship between file a and file B is mapped using dirname (_ file. This will not cause path errors when different directories are included for multiple times! Note _ file __indicates the file name of the file where the code is located. For example, if C uses dirname (_ file _) to contain a, the _ file _ code is a C file, when C contains a and dirname (_ file _) is used to include B,
Then _ file _ is the file during execution, and so on. The file inclusion and path will never go wrong!

The path of _ file _ is the file where the current code is located.

 

Dirname (_ file _); the directory name at the top of the file is obtained.

Dirname (_ file _); the directory name of the file's layer is obtained.

"../" Is suitable for a simple file containing another file. Most dirname (_ file _) is suitable for multiple layers, more complex file inclusion, and easier maintenance. If only the. php file contains the B. php file, you can directly use the dirname (_ file _) or "../" of the include file. Generally, no error occurs. But usually a contains B files, and C. if PHP contains file a, use ".. /", it will cause the path error when C contains a and then loads B files, and when dirname (_ file _) is used, when C contains a, It maps the path relationship between C and A with dirname (_ file,
When file a contains file B, the corresponding directory relationship between file a and file B is mapped using dirname (_ file. This will not cause path errors when different directories are included for multiple times! Note _ file __indicates the file name of the file where the code is located. For example, if C uses dirname (_ file _) to contain a, the _ file _ code is a C file, when C contains a and dirname (_ file _) is used to include B,
Then _ file _ is the file during execution, and so on. The file inclusion and path will never go wrong!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.