PHP dirname (__file__)

Source: Internet
Author: User

__FILE__:

explanation: the full path and file name of the file. If used in the include file, the include filename is returned. Since PHP 4.0.2, __file__ always contains an absolute path, and the previous version sometimes contains a relative path.

String dirname (String path)
Explanation: Given a string containing a full path to a file, this function returns the directory name after the file name has been removed.

Note: in Windows, slashes (/) and backslashes (\) can be used as directory separators. In other environments it is a slash (/).

If you use dirname for nesting?

dirname (DirName (__file__));  
Assume __file__ is/wwwhome/web/config/config.php  
The method output is/wwwhome/web  
DirName (dirname (__file__)), which is the top directory name
DirName (__file__) of the file, and the directory name

Summary: We all know that the folder List and file list will be listed when you enter Dir under DOS, and the parameters in the DirName function will also be processed if they are folder names. That is, you can use this function if you want to get a parent directory of this level of directory

PHP dirname (__file__)

Related Article

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.