Absolute path deemed incorrect in "require_once()"

So this is the error:

Warning: require_once(/__sys/routine.php): failed to open stream: No such file or directory in C:\xampp\htdocs\__sys\member.login.php on line 4.

Because I hoped the script would go
127.0.0.1
then
127.0.0.1/__sys/
then include
127.0.0.1/__sys/routine.php

Yes, I’m absolutely sure that the path is correct.

I don’t like relative paths because it requires remembering a lot. While absolute paths are always the same, regardless where script is.

So, is there a way to fix it, or bypass it, or other method to execute it?

The line is literally: require_once("/__sys/routine.php");

PS: My script is hosted directly in 127.0.0.1, not in sub-folder in htdocs.

PHP’s require/include operate on the file system, not on the URL!

i.e. require_once('/__sys/routine.php') resolves to C:\__sys\routine.php.

4 Likes

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