Re: problem about a scope of varibales
| From: | Joel Ricker | Date: | Sat, 29 Sep 2001 06:27:19 +0000 |
| Subject: | Re: problem about a scope of varibales | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69256@lists.php.net to get a copy of this message | ||
I'm not sure what problem you may be having. I copy and pasted your code as
is and it seems to work fine. Are you saying that this line is giving an
error of some sort:
echo "<BR>The contents of GlobalVariable are $GLOBALS[GlobalVariable]";
If so then try quoting GlobalVariable to read $GLOBALS["GlobalVariable"].
It shouldn't be a factor since its my understanding that the two conventions
are synonymous.
The result I got:
Calling Our function for the first time...
The contents of GlobalVariable are Global
The contents of LocalVariable are Local
The contents of StaticVariable are 0
If this isn't it, let me know what you are looking for.
Joel
hi all,
i am in trouble so please help me if possible what is wrong in this code
<?php
$GlobalVariable = "Global";
function local()
{
$LocalVariable="Local";
static $StaticVariable=0;
echo "<BR>The contents of GlobalVariable are $GLOBALS[GlobalVariable]";//i
have found an error in //this line
echo "<BR>The contents of LocalVariable are $LocalVariable";
echo "<BR>The contents of StaticVariable are $StaticVariable";
return $StaticVariable=$StaticVariable+1;
}
echo "<B>Calling Our function for the first time...</B>";
local();
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net