Reputation: 990
I'm having a trouble deploying my website. I've been building it under Windows, with WAMP and now I'm deploying to Linux.
Code like this works on Windows:
req.php
echo "This is req<br>";
ini_set("include_path", "/home/clash/public_html/:".get_include_path());
require "/req1.php";
req1.php
echo "This is req1";
But fails in the production environment with the message:
Warning: require(/req1.php) [function.require]: failed to open stream: No such file or directory in /home/clash/public_html/req.php on line 5
Fatal error: require() [function.require]: Failed opening required '/req1.php' (include_path='/home/clash/public_html/:.:/usr/lib/php:/usr/local/lib/php') in /home/clash/public_html/req.php on line 5
The path in ini_set is the path of the actual location of the website on the server filesystem.
I wouldn't like to avoid absolute paths as a library that I use relies on them somewhat.
I am sure that I'm missing something very simple here, but I can't figure out what.
Thanks!
Upvotes: 1
Views: 677
Reputation: 146370
You can replace the hard-coded path separator with the PATH_SEPARATOR
constant. That way you ensure that your value for include_path
is cross-platform.
Upvotes: 0
Reputation: 7993
On Linux, /
is the root of the filesystem, similar to C:\
on Windows. Remove the leading /
and it will work as expected.
Upvotes: 2