首頁 >後端開發 >php教程 > php资料路径的操作

php资料路径的操作

WBOY
WBOY原創
2016-06-13 13:08:591035瀏覽

php文件路径的操作

$url = 'http://'.$_SERVER['HTTP_HOST'].substr($REQUEST_URI,0,strrpos($REQUEST_URI,'/'));
echo $url;
echo "

";
//echo strrpos($REQUEST_URI,'/');
//echo substr($REQUEST_URI,0,strrpos($REQUEST_URI,'/'));
echo dirname($_SERVER['SCRIPT_FILENAME']);
echo "

";
echo $_SERVER['PHP_SELF'];
echo "

";
echo $_SERVER['SCRIPT_NAME'];
echo "

";
echo $db=$_SERVER['DOCUMENT_ROOT'].'/access/db.mdb';
echo "

";
echo realpath("");
echo "

";
echo $_SERVER['DOCUMENT_ROOT'];
echo "

";
echo "

";
echo $_SERVER['DOCUMENT_ROOT']."
";?? //获得服务器文档根
echo $_SERVER['PHP_SELF']."
"; //获得执行该代码的文件服务器绝对路径
echo __FILE__."
"; //获得文件的文件系统绝对路径
echo dirname(__FILE__); //获得文件所在的文件夹路径


结果
http://localhost/test

F:/kuikoo/test

/test/url.php

/test/url.php

F:/kuikoo/access/db.mdb

F:\kuikoo\test

F:/kuikoo

?

F:/kuikoo
/test/url.php
F:\kuikoo\test\url.php
F:\kuikoo\test

?

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn