Vikas Jayna Posted March 20, 2008 Share Posted March 20, 2008 I've recently upgraded from PHP 4.3.2 (cgi) to PHP 5.2.4 (cli). As a result I'm facing the following issue while running php from the command line: I execute a file a.php in my home directory as php -q a.php the file a.php includes a php file like this include ("/var/www/html/b.php") the file b.php further has includes like include("c.php") now the file c.php is located within /var/www/html but the newer php version looks for the file in my home directory while the older version looks for it in /var/www/html A workaround for this that I've used is to change the current directory using the chdir function to /var/www/html and it works but this process becomes quite cumbersome if the script is having a number of includes this way from separate directories. Is there any configurational change that can be done in php to avoid these issues? Link to comment https://forums.phpfreaks.com/topic/97034-how-to-handle-includes-within-include-files/ Share on other sites More sharing options...
rajtest Posted March 20, 2008 Share Posted March 20, 2008 Hi, include means actually the whole file is included into the calling php page. So if you include var/www/html/b.php file in a.php then in a.php the whole file what you are calling from the path it fetches and includes into the a.php file. and if you call again c.php in the file var/www/html/b.php, it looks for the file which is at in the a.php directory, so you will get a warning message. In the same way if you run the var/www/html/b.php file directly in the command prompt then for c.php it looks at var/www/html directory. I hope there is no other way to giving of relative urls, It is much better to give relative urls. Link to comment https://forums.phpfreaks.com/topic/97034-how-to-handle-includes-within-include-files/#findComment-496578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.