This has been giving me a headache. I've read multiple questions but none helped me.
So I need to include php files from different folders. Here's how my structure looks like. I'm using WAMP.
/C
/wamp
/www
/project1
/main
/backend
-class.common.php
-inc.config.php
/providers
/google
-google.functions.php
So as clear from the structure above, class.common.php is under folder backend (Which is under folder main).
Now, I'm trying to include class.common.php in google.functions.php using THIS code :-
include '../../class.common.php';
However, this doesn't seem to work. I've even tried working with the __DIR__
constant. No luck. What's the most robust way to achieve my result?
PHP Error Log.
[15-Jun-2016 22:16:25 Europe/Paris] PHP Warning: include(../../_inc_config.php): failed to open stream: No such file or directory in C:\wamp\www\yele\main\backend\api_providers\rech\api_functions.php on line 3
[15-Jun-2016 22:16:25 Europe/Paris] PHP Stack trace:
[15-Jun-2016 22:16:25 Europe/Paris] PHP 1. {main}() C:\wamp\www\yele\main\backend\ajax.php:0
[15-Jun-2016 22:16:25 Europe/Paris] PHP 2. include() C:\wamp\www\yele\main\backend\ajax.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP 3. include() C:\wamp\www\yele\main\backend\class.apibase.php:3
[15-Jun-2016 22:16:25 Europe/Paris] PHP 4. include() C:\wamp\www\yele\main\backend\api_providers\rech\base_lib.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP Warning: include(): Failed opening '../../_inc_config.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\yele\main\backend\api_providers\rech\api_functions.php on line 3
[15-Jun-2016 22:16:25 Europe/Paris] PHP Stack trace:
[15-Jun-2016 22:16:25 Europe/Paris] PHP 1. {main}() C:\wamp\www\yele\main\backend\ajax.php:0
[15-Jun-2016 22:16:25 Europe/Paris] PHP 2. include() C:\wamp\www\yele\main\backend\ajax.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP 3. include() C:\wamp\www\yele\main\backend\class.apibase.php:3
[15-Jun-2016 22:16:25 Europe/Paris] PHP 4. include() C:\wamp\www\yele\main\backend\api_providers\rech\base_lib.php:2
[15-Jun-2016 22:16:25 Europe/Paris] PHP Fatal error: Cannot redeclare class common in C:\wamp\www\yele\main\backend\class.common.php on line 5
[15-Jun-2016 22:16:25 Europe/Paris] PHP Stack trace:
[15-Jun-2016 22:16:25 Europe/Paris] PHP 1. {main}() C:\wamp\www\yele\main\backend\ajax.php:0
[15-Jun-2016 22:16:25 Europe/Paris] PHP 2. include() C:\wamp\www\yele\main\backend\ajax.php:3