cannot define WEB_ROOT

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aals
Forum Newbie
Posts: 2
Joined: Sun Jan 02, 2011 5:49 am

cannot define WEB_ROOT

Post by aals »

Code: Select all

<?php 

ini_set('display_errors', 'On');
error_reporting(E_ALL);
$thisFile = str_replace('\\','/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];

$webRoot="";
$srvRoot="";

$webRoot =  str_replace(array($docRoot, 'testing.php'), '', $thisFile);
$srvRoot = str_replace('testing.php', '', $thisFile);

define('WEB_ROOT', $webRoot); 
define('SRV_ROOT', $srvRoot);

echo WEB_ROOT; //doesn't display this
echo SRV_ROOT; //doesn't display this

echo 'thisFile- '.$thisFile ;//works perfect
echo "<br>";
echo 'docRoot- '.$docRoot;//works perfect
echo "<br>";


echo 'webroot- '.$webRoot ;//works perfect

echo "<br>";
echo 'srvroot- '.$srvRoot ;//works perfect
?>
when i echo WEB_ROOT/SRV_ROOT it doesn't display value
but displays values when i echo $webRoot or $srvRoot
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: cannot define WEB_ROOT

Post by Darhazer »

works for me 8)

PHP and OS versions ?
result from var_dump(WEB_ROOT) ?
aals
Forum Newbie
Posts: 2
Joined: Sun Jan 02, 2011 5:49 am

Re: cannot define WEB_ROOT

Post by aals »

php version 5.3.0 & OS is win xp
result from var_dump(WEB_ROOT); is -> string(0) ""
Post Reply