PHP require absolute path not working

Website url

Test url:

My issue

PHP script:

	require_once "/includes/head_tags.php";

(yes,it is so simple and was only used to test)

This is what my /htdocs/includes folder looks like:

And I’m getting this when visiting the page:

Warning: require_once(/includes/head_tags.php): failed to open stream: No such file or directory in /home/vol19_1/ on line 2

Fatal error: require_once(): Failed opening required '/includes/head_tags.php' (include_path='.:/usr/share/pear/') in /home/vol19_1/ on line 2

Changing /includes/head_tags.php into /htdocs/includes/head_tags.php didn’t work.

Any ideas of why is this ever happening?
The relative path is indeed working for me without any problem.

Try to use __DIR__."/includes/head_tags.php" as require path and see if it works. __DIR__ references /home/vol19_1/ in this case.


Yes it worked.
Thank you for your assistance. :grinning:

(I pretty much believed that this __DIR__ thing shows up nowhere in docs…)


You’re welcome as always :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.