Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php include file that has includes

I am working on a site and have been asked to include files that are sitting in a folder above my php scripts. Problem is those php files I have been asked to include, have includes in them. And thus the files they refer to cannot be found when calling my php pages.

What is the best way to handle this situation?

like image 239
user1157576 Avatar asked Aug 04 '26 16:08

user1157576


1 Answers

When including a file from folder B to folder A, the B script acts like it was stored in A. Either change your pointer paths or chdir().

https://www.php.net/manual/en/function.chdir.php

Or use full paths rather than local. Such as

$home = '/home/user/path/to/root/;

Include_once($home .'folderb/script.php');

like image 134
tim Avatar answered Aug 07 '26 04:08

tim