2016-02-12

The project is under git, and the same php script has no trouble finding the file in another git installation, both on the same revision of the same branch. I looked at untracked .htaccess and local php.ini files to see if any differences there could have caused a problem, but I didn't see anything pertinent.

When I run the script from "installation 1", it doesn't matter what directory I'm in when I type the command.

buttle@butkus.com $ [/home/installation1]# php -f
public_html/somescript.php It works! buttle@butkus.com $
[/home/installation1]# cd public_html buttle@butkus.com $
[/home/installation1/public_html]# php -f somescript.php It works!
buttle@butkus.com $ [/home/installation1]# cd /home/installation2
buttle@butkus.com $ [/home/installation2]# php -f
public_html/somescript.php Fatal error: require_once(): Failed
opening required '/home/installation2/[public_html should be
here!!]path/to/some/php/file/shell/../../../../../../shell
/abstract.php' (include_path='.:/usr/local/lib/php') in
/home/installation2/[public_html should be
here!!]path/to/some/php/file/shell/run.php on line 15

The problem is that the above file path is missing the public_html folder! And so the relative path descends too far down, into installation2 folder before looking for the shell folder, which is not there. It's in public_html. Why is this changing depending on where I am when I run the script? Why does it work in the other installation?

Could it have anything to do with my xdebug php.ini settings? Or <Files> rules in .htaccess?

Actual Content URL:http://stackoverflow.com/questions/35237596/php-script-using-incorrect-relative-path-leading-to-fatal-error-opening-required

Show more