$_SERVER['document_root'] returns /htdocs not /public_html

你说的曾经没有我的故事 提交于 2019-12-05 11:54:37

I'd suggest to use the __FILE__ constant and work out your htdocs folder from there. It's much more reliable than relying on the $_SERVER superglobal, since that actually differs from server to server.

Example (that you'd call in your index.php in root folder):

$htdocs = str_replace(basename(__FILE__), __FILE__, '');
define('ROOT_FOLDER', $htdocs);
require_once(ROOT_FOLDER . '/includes/head.php');

For future reference (if anyone has similar issues), it turns out that the problem was with their test server. I launched it with my code as-was (risky, I know), and all turned out well.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!