On 13/09/2021 21:17, Bo Berglund wrote:
They might show different paths, it all depends on the main script being
run (autoloaders are your friend here). But you can use it to generate
paths using some basic string concatenation (and some file methods if
you want some better error case handling).
On Mon, 13 Sep 2021 20:36:35 +0100, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
THen seemingly all worked, but only until a call was made to a php file at a
deeper location which also included this file...
Have you looked at __DIR__ ?
Yes, I have tested this php file located in the htdocs/ dir:
echo "Including: " .dirname($_SERVER['DOCUMENT_ROOT'],1)."/php/logindata.php";
echo "<br>Mail sender= " . $mailsender ;
echo '<br>Dir= ' . __DIR__ ;
echo "<br>DocRoot= " . dirname($_SERVER["DOCUMENT_ROOT"],1) . "/";
The output was this:
The strange thing is that even though I have set include_path according to the
selected solution in this stackoverflow thread:
it does not pick up the logindata.php file where $mailsender is defined.
If I move the test php file into /php then it picks up the information since it
is in the same dir.
Note that __DIR__ and dirname($_SERVER['DOCUMENT_ROOT'],1) return completely
It really seems very strange that they have removed this function without
supplying a new version...