Jump to content

How does include path resolution work in require_once?

Recommended Posts


I have a web dirs like this


Contents of these files:


require_once '../obj/a.php';


require_once 'b.php';


require_once 'c.php';

then I run d.php, the log display:

PHP Warning:  require_once(c.php): failed to open stream: No such file or directory in /var/www/xxx/test/b.php
PHP Fatal error:  require_once(): Failed opening required 'c.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/xxx/test/b.php

Is there something obvious I'm missing? how do include paths work in PHP?


Link to post
Share on other sites

I think you're missing something to tell us.

I've recreated the same environment as yours and also added an echo "Ok!"; in the c.php and at me it works fine, exactly the same settings as yours.

As i did it, i used Windows to do it, so it might aswell be the thing that you're using linux, and it might be possible that the paths don't work as are working in windows. Try putting the "../obj/c.php"; as path in the b.php althought you have it in the same directory and see if that works, if not then i don't know what should work as on my pc (windows) works just fine.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...