0

I have to two include_once calls in my code:

include_once('../folder/folder/file.php');
include_once('../folder/folder/file2.php');

Its the correct file locations and was able to verily with echo realpath()

If I take one of them out, my code works minus what I need from the other file.

If I have both of them, I just get a blank screen, no error.

My question is, does php like two include_once starting with .. and how can I test which one is failing?

user1269625
  • 3,121
  • 26
  • 79
  • 111
  • 3
    Use `__DIR__` constant and include absolute paths to your files. Also enable `error_reporting()` and set `display_errors` to true to see what's the error. – Tomasz Kowalczyk Feb 26 '14 at 20:46
  • 1
    enable error display there is no reason for 2 include to break the site. – Abhik Chakraborty Feb 26 '14 at 20:46
  • (1) multiple `include_once`'s are totally OK (2) read [How to get useful error messages in PHP](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) – Wrikken Feb 26 '14 at 20:46
  • 2
    You obviously have some conflict between file.php and file2.php. – Brad Feb 26 '14 at 20:46
  • 1
    Something like the same named function defined in both is a likely possibility for a fatal error. Go look in your error log (which is what a blank screen means in PHP) then turn on `display_errors` as suggested. Easy at runtime with `ini_set('display_errors', 1);` _Always do this_ when developing code. – Michael Berkowski Feb 26 '14 at 20:47
  • Use `include_once(dirname(__FILE__) . '/../folder/folder/file.php');` – Tomanow Feb 26 '14 at 20:59

1 Answers1

0

The issue you have is most likely that file one or file two read other files relevant to their directory. For example, if file one has code that says fopen(file.txt), then you should change that to fopen(../folder/folder/file.txt).

Make sure all statements in file one and file two that access other files use a path that is relative to the file that has the include_once statement.

Anton Koenig
  • 39
  • 1
  • 11