,例如:"/www/work/es_demo1/index.php"
在url域名中,根目录由网址开始,例如:"www.php20.cn/admin/index.php"
如以上这种情况,直接从根目录开始的路径...在url域名中,代表着:"域名/work/www/es_demo/index.php".
例如:
<?php
echo getcwd();
在windows中:
?
在linux中:
?...$test2TxtAbsolute2),"";
echo file_get_contents($test2TxtRelative),"";
同样,我们可以使用"...../"来表示上级目录
在test3.php中,使用"../"来调用test.txt和test2.txt写法如下:
<?php
echo "所在目录:".getcwd().".../test.txt");
调用index.php 输出结果:
?
很明显,路径是以调用的文件为基准的.那该如何获取到test.php的目录呢?
可通过__DIR__常量获取当前文件目录