2

Any idea what could cause a PHP file to execute fine in the browser, but give an error when run in the command line interface?

So to be specific, when I visit mysite.com/script.php in a browser, all is well.

When I execute php -f /var/www/mysite.com/public_html/script.php I get an error that one of my required files cannot be found.

So, the error message gives a lot of insight, but I am confused because it works as intended in the browser with no error, so I have no idea what could cause this behavior. Any ideas?

sotirov
  • 4,379
Zack
  • 123

1 Answers1

2

By starting with ../, which is relative to the current working directory of the process, the require will only work if you are in the right directory. If you have control of the script, change it to use the full, absolute path starting at /,

A.B.
  • 92,125
waltinator
  • 37,856