本文介绍了将文档根目录定义为ROOT_PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用一些常量来定义要构建的网站上特定目录的路径,例如:
I use some constants to define paths to specific directories on a website that I'm building, like this:
define("ROOT_PATH", "website/"); 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", "website/");和
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/");因为它将尝试加载
website/home/username/public_html/image.png您不想要的。
使用
define("ROOT_PATH", "website/");将尝试获取
website/image.png这是什么你想要的。
更多推荐
将文档根目录定义为ROOT
发布评论