Home > Backend Development > PHP Tutorial > 关于获取网站根目录的有关问题

关于获取网站根目录的有关问题

WBOY
Release: 2016-06-13 12:11:58
Original
1176 people have browsed it

关于获取网站根目录的问题
域名访问:http://www.123.com
IP访问:http://123.123.123.123/hei

请问怎么不管用域名还是IP访问都能得到正确的根目录。$_SERVER['HTTP_HOST']用域名可以,但用ip就不对了
------解决思路----------------------

__DIR__
dirname($_SERVER['SCRIPT_FILENAME'])
getcwd
------解决思路----------------------
上传目录为接收上传的程序文件所在目录的相对路径即可

------解决思路----------------------
使用相对路径吧。
------解决思路----------------------
相对路径 字数补丁

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template