lamp环境中的/到底是指的网站根目录还是linux的根

在lamp中经常会用到 require,require_once等包含文件的语句。

如果你使用相对路径没有问题。

但是如果你使用了这样的语句就要小心了。

对于如图网站目录

require_once '/include/common.inc.php';

这里你需要对/代表的路径非常清楚。/代表的是哪个路径呢?

如果代表网站目录,没有问题。

但是我再使用发现,如果这样写的话服务器会产生500错误。

如果/代表的时候linux的根的,应该怎么写路径的。

/document_root/include/common.inc.php

尝试一下,/usr/local/httpd/htdocs/include/common.inc.php

果然可以。

至此,确认/在lamp环境中代表的linux的根。

include_path问题,没有测试。

require_once "a.php";

会到include_path目录搜索a.php文件。没有测试。

如果感觉不错,请 一个!
by simpman
原文地址:https://www.cnblogs.com/simpman/p/3147765.html