开发者

Why is this "require" causing a fatal error?

开发者 https://www.devze.com 2023-03-26 06:34 出处:网络
I inherited a file called promo.php.It begins with the lines: define(\'ROOT\', dirname(dirname(dirname(__FILE__))));

I inherited a file called promo.php. It begins with the lines:

define('ROOT', dirname(dirname(dirname(__FILE__))));
require_once ROOT. '/app/config/database.php';
require_once ROOT. '/app/config/constants.php';
开发者_JS百科

And works well enough. For testing purposes though I created a file called promo-2.php in the same folder, beginning with the same lines. In this case, the file dies with a fatal error at at the first require.

As far as I can make out, the required file is not being found. But how can this be the case when promo-2.php is in the some directory as promo.php? Surely ROOT will be the same in both places? Could there be some kind of permissions issue that I haven't thought of? All suggestions gratefully received!


Hmm, there was a helpful suggestion but it seems to have been deleted now. Looking at the files, one was owned by root and one by another user; I assume that this affects the ability to require other files, though someone else can tell me for sure!

In any case (without having been granted the shell access to change the ownership), amending the root-owned file to contain the promo-2.php code allowed that code to work. So I guess there's nothing wrong with the code or path above, it was just an ownership stroke permissions issue. In the unlikely event that anyone was wondering!

0

精彩评论

暂无评论...
验证码 换一张
取 消