I have two PHP files (NOT in the same directory) and one properties file, like so:
a.php
-----
<?php
echo "one";
include("/path/to/b.php");
echo "three";
and
b.php
-----
<?php
$num = file_get_content("b.properties");
echo $num;
where b.properties has two in it.
Since a.php and b.php are not in the same folder, the include in a.php causes the properties file not to load properly.
How do I go about fixing this? Note that I cannot modify b.php or b.properties or obviously this would be a trivial question.
a.phpto the same folder asb.php? I'm not sure if I understand well what your problem is. When you write a question about an error, always include details of the error. Add error reporting to the top of your file(s) right after your opening PHP tag for example<?php error_reporting(E_ALL); ini_set('display_errors', 1);then the rest of your code, to see if it yields anything.file_get_contentsinb.php. This is the problem with using relative paths. The arbitrary constraints you're creating around this problem lead me to believe that it's contrived and most likely an X/Y Problem which aren't very welcome on StackOverflow.a.phpis a web-served page, whileb.phpis not in the webroot and needs to stay that way. The only way it can be hit is ifa.phpcalls it.$_SERVER['DOCUMENT_ROOT'] . "../path/to/b.properties");