Reputation: 63
I have two folders Provider
and Library
in the same directory. Provider
includes two php files ActiveRequests.php
and PendingRequests.php
. Library
contains another folder Multilingual
which includes Pagefactory.php
and languageSession.php
- Provider
- ActiveRequests.php
- PendingRequests.php
- Library
- Multilingual
- Pagefactory.php
- languageSession.php
I'm including PageFactory.php
in ActiveRequests.php
like
include_once __DIR__ . '/../library/Multilingual/PageFactory.php'
and it is working fine.
But when I'm trying to include PageFactory.php
in PendingRequests.php
in the same way like
include_once __DIR__ . '/../library/Multilingual/PageFactory.php'
it is not working.
when I tried to include the languageSession.php
in Pendingrequests.php
like
include_once __DIR__ . '/../library/Multilingual/languageSession.php'
it is working fine.
Can any one help me? What could be the problem with the PageFactory.php
path?
I've also tried with $_SERVER["DOCUMENT_ROOT"]
but it did not work.
Upvotes: 1
Views: 2850
Reputation: 1074
I've just fix a same problem, the point is if you include PageFactory.php
in PendingRequests.php
you have to change every file that PageFactory.php
refers base on PendingRequests.php
path. I fixed my problem with this way.
Upvotes: 1
Reputation: 1360
Try printing the path as
echo __DIR__ . '/../library/Multilingual/PageFactory.php';
In this way, you can check if the path to the file is correct!
Or use, var_dump
to check the path!
To The people downvoting my answer: Printing the path is for debugging!
Or you can check the path as :
var_dump(file_exists(__DIR__ . '/../library/Multilingual/PageFactory.php'));
__DIR__
is the path to the parent directory. It gives path of Provider
when used from PendingRequests.php
.
I think the problem is you have used ../
.Try removing it!
For example,
__DIR__ . '/../library/Multilingual/PageFactory.php'
is identical to
path/to/Provider/../library/Multilingual/PageFactory.php
So the final answer is to remove "../" and it becomes:
__DIR__ . '/library/Multilingual/PageFactory.php'
Upvotes: 0
Reputation: 237865
The obvious problem is that you include the file with the following:
include_once __DIR__ . '/../library/Multilingual/PageFactory.php'
While the file is called Pagefactory.php
.
On non-Windows systems, this will make a difference. Ensure that the capitalisation is correct.
This may just be a typo in your question (the amount of typos in it originally would suggest it could be!) but it may be the cause of the problem.
Upvotes: 0