August 31, 201313 yr Okay, so this is going to sound like the most amature question ever. I remember needing to do something like this years ago but never figured it out, so here i am. I have a structure like the following: ------------- index.php (Includes file1.php FOLDER1 > file1.php (This includes file2.php) FOLDER2 > file2.php -------------- So, index.php includes file1.php perfectly. But then errors out with file2.php. It says it cannot open stream. File not found. I have changed file.php to the following configs but with no success... include('../FOLDER2/file2.php'); include('FOLDER2/file2.php'); include('/FOLDER2/file2.php'); include('../../FOLDER2/file2.php'); Any idea how i can go about this? Thanks in advance!
August 31, 201313 yr Author Try: include(__DIR__ . '/file2.php'); Had to change is slightly to: include(__DIR__ . '/../file2.php'); But it worked! Thank you very much!!
Create an account or sign in to comment