PHP如何获取当前脚本所在物理目录

如果用$_SERVER['DOCUMENT_ROOT'];需要开启php服务器相应的选项,不如下面的方法简单,当然,执行效率也许不高。

echo substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"\\")+1);

Leave a Reply

Your email address will not be published.