I can\'t believe PHP doesn\'t have an easy solution for this simple matter. ASP.NET has a ~ sign that takes care of this issue and starts everything from the root level. Her
Create a constant with absolute path to the root by using define in ShowInfo.php:
define('ROOTPATH', __DIR__);
Or PHP <= 5.3
define('ROOTPATH', dirname(__FILE__));
Now use it:
if (file_exists(ROOTPATH.'/Texts/MyInfo.txt')) {
// ...
}
Or use the DOCUMENT_ROOT defined in $_SERVER:
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/Texts/MyInfo.txt')) {
// ...
}