将文档根目录定义为ROOT_PATH [英] Defining the document root directory as the ROOT_PATH
本文介绍了将文档根目录定义为ROOT_PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用一些常量来定义要构建的网站上特定目录的路径,例如:
I use some constants to define paths to specific directories on a website that I'm building, like this:
define("ROOT_PATH", "http://website.com/");
define("IMAGES_DIR", ROOT_PATH . "images/");
,我通常这样使用它们:
and I usually use them like this:
echo "<img src='" . IMAGES_DIR . "some_image.jpg' />";
现在我想知道之间是否有任何区别
now I want to know if there is any difference between
define("ROOT_PATH", "http://website.com/");
和
define("ROOT_PATH", "/home/username/public_html/");
我应该使用哪一个?为什么?
and which one of them should I use? And why?
推荐答案
您不能真正使用以下内容:
You can't really use the following:
define("ROOT_PATH", "/home/username/public_html/");
因为它将尝试加载
http://website.com/home/username/public_html/image.png
您不想要的。
使用
define("ROOT_PATH", "http://website.com/");
将尝试获取
http://website.com/image.png
这是什么你想要的。
这篇关于将文档根目录定义为ROOT_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文