Jump to content

How does include path resolution work in require_once?


joymis

Recommended Posts

Hello,

I have a web dirs like this

/
obj/
    a.php
    b.php
    c.php
test/
    d.php

Contents of these files:

d.php:

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

a.php:

require_once 'b.php';

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?

thanks.

Link to comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...