您的位置:首页 > 编程语言 > PHP开发

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

2007-11-06 12:09 281 查看
<script type="text/javascript"><!--
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


<?   


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中一直想得到一个这样的函数,一直搞不定,搞得每次都要手改地址

如果哪位知道麻烦告诉我,谢谢。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息