Some people like to make a list of slash, such as $ dir = dirname (__ FILE__). '/'; Some people find it troublesome and code is not good, directly with $ dir = dirname (__FILE__);
So when we want to include files there may be problems. For example, to include test.php, if it is dirname (__FILE__). '/test.php', of course no problem, if there is no slash, such as dirname (__ FILE__). 'Test.php', then the problem is coming Find D: webtest.php becomes D: webtest.php.
solution: Directory constants or variables used ./ instead / such as: include 'D: /web./test.php'; include 'D: / web /./test.php'; All equal include 'D: /web/test.php';
This eliminates the need to consider whether the directory name is added /, and when using constants or variables to get the directory, the display will be more intuitive. Such as: define ('ROOT_PATH', dirname (__ FILE__). '/'); include ROOT_PATH. './test.php'; ratio include ROOT_PATH. '/test.php'; include ROOT_PATH. 'test.php'; Easier to intuitively determine the file as a file under ROOT_PATH
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.