-★出爺;3 发表于 2017-3-29 10:08:42

PHP取得当前文档所在的目录

<?
functiongetcwdOL(){
$total=$_SERVER;
$file=explode("/",$total);
$file=$file[sizeof($file)-1];
returnsubstr($total,0,strlen($total)-strlen($file)-1);
}
$currenturl=getcwdOL()//取得当前目录
?>

  例如文件所在的url为http://localhost/eng/ss/1.php
  输出的值为eng/ss
  ASP中一直想得到一个这样的函数,一直搞不定,搞得每次都要手改地址
  如果哪位知道麻烦告诉我,谢谢。
页: [1]
查看完整版本: PHP取得当前文档所在的目录