0

Problem when i am using $webRoot / $srvRoot as a value for a variable or in defining a constant
Code & problem is below:

<?php 

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

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


define('WEB_ROOT', $webRoot); //error on this line Variable Undefined
define('SRV_ROOT', $srvRoot); //error on this line Variable Undefined

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
?>

what is it that i am doing wrong?

Pls help me!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by aals
0

First of all, it is only providing a Notice.It isn't a show stopper. The PHP interpreter seems to want a simple definition first. If you add:

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

before line 8, the notice goes away.

0

thanks the notice went away but when i echo WEB_ROOT it doesnt display value
but displays values when i echo $webRoot or $srvRoot

Edited by aals: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.