1

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.

2
  • Are you sure you didn't make any typo's? Commented Nov 7, 2013 at 14:42
  • 3
    How do you know it's not working? i.e. what symptoms/errors do you see? What do you see if you use require_once() rather than include_once()? Commented Nov 7, 2013 at 14:42

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.