Search code examples
phpubuntuincludeinclude-path

As soon as I try to include a file inside a folder, my relative paths break?


Just wondering what I'm doing wrong here. I've been setting up a linux dev environment. If I do something like this:

include 'test.php';

It works great.

If I then move my test.php file into a folder called test and do this:

include 'test/test.php';

It fails. What is going on?

I have also tried:

include '/var/www/site/test/test.php';
include '/test/test.php';
include '../test/test.php';

etc, with no luck.


Solution

  • The folder containing you include file (and any other nested folders you ask php engine to access) should have its executable flag set.

    In a linux terminal:

    chmod a+x /var/www/site/test
    

    to check permissions:

    ls -l /var/www/site | grep "test"