PHP Warning: include(): Failed opening

196

I have this error on my site after I moved it from a shared hosting to a VPS (both with cPanel).

PHP Warning: include(): Failed opening '../../../transporturi/a.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in [...] on line 36.

In the other file on line 36 I have included a PHP file, I checked the path and it's there. I also tried to switch PHP version from the WHM from 5.5 to 5.6 to 7.0, but no luck.

25

Answer

Solution:

The path is relative to the file that received the request, so you can use the PHP DIR magic constant to know what is your current directory:

echo(__DIR__);

and then form the absolute path relative to your file as below.

include(__DIR__ . '../../../transporturi/a.php');

Now it depends on your directory structure and the location of both the included file and the one where its included.

People are also looking for solutions to the problem: php - Error Composer Installation

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.