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


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

 

例如文件所在的url为http://localhost/eng/ss/1.php

输出的值为eng/ss

 ASP中一直想得到一个这样的函数,一直搞不定,搞得每次都要手改地址

如果哪位知道麻烦告诉我,谢谢。

你可能感兴趣的:(PHP)