Some people like to add a slash, for example, $ dir = dirname (_ FILE __). '/'; while some people are too troublesome and the code is not beautiful, use $ dir = dirname (_ FILE __); in this way, problems may occur when we want to include files. For example, to include test. php, if it is dirname (_ FILE _). '/tes
Some people like to add a slash, for example, $ dir = dirname (_ FILE __).'/';
Some people are too troublesome and the code is not beautiful. use $ dir = dirname (_ FILE _) directly __);
In this way, problems may occur when we want to include files.
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. for D: \ web \ test. php becomes D: \ webtest. php.
Solution:
Directory constants or variables are replaced/
For example:
Include 'd:/web./test. php ';
Include 'd:/web/./test. php ';
Are equivalent
Include 'd:/web/test. php ';
In this way, you do not need to consider whether/is added after the directory name, and the display will be more intuitive when the directory is obtained using constants or variables.
For example:
Define ('root _ path', dirname (_ FILE __).'/');
Include ROOT_PATH. './test. php ';
Ratio
Include ROOT_PATH. '/test. php ';
Include ROOT_PATH. 'test. php ';
It is easier to intuitively determine that the file is under ROOT_PATH.