我在开发中使用以下内容来定义根目录:
define('LOCAL_URL', 'http://localhost/~xampp/Mysite');
define('REMOTE_URL', 'http://example.com');
define('DEV_VERSION', true);
if(DEV_VERSION)
define('URL', LOCAL_URL);
else
define('URL', REMOTE_URL);
对于我来说,这个概念是新的,而且我有点 PHP 的初学者,所以请温柔一点。
我试图在 'require_once' 中使用 'URL',但似乎无法使其工作(即所需文件未包含)。 我尝试了以下方法:
require_once URL.'/phpincludes/coming-events.php';
require_once(URL.'/phpincludes/coming-events.php');
require_once URL . '/phpincludes/coming-events.php';
require_once (URL . '/phpincludes/coming-events.php');
require_once(URL.'phpincludes/coming-events.php');
我已经查看了 http://www.php.net/manual/zh/function.require-once.php,并在 Stackoverflow 进行了搜索,但仍然没有取得任何进展。
我确定我可能犯了一个非常愚蠢和基础的错误,但我现在不知所措,真的需要帮助!
<base href = ...>
中使用它进行补偿即可)。 - mario<img src="<?php echo URL ?>/images/something.jpg">
- circey