Each week I feature one of my answers on stackoverflow hoping it might help other people.
This weeks question by Junaid Nisto: Forward slash in include/require doesn’t go to root
Isn’t for example this supposed to go to the server root on a site and get the sometext.txt from there?:
<?php require '/sometext.txt'; ?>
When I run this in a script, I get “failed to open stream: No such file or directory”.
I vaguely remember using the forward slash in a require/include function before, and that it has worked..
I use Apache as webserver.
I think you need a dot in front of the slash
<?php require('./sometext.txt'); ?>
or something like this would be better
<?php require $_SERVER['DOCUMENT_ROOT'].'/sometext.txt'; ?>