|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-21 09:59 UTC] yippaolo at yahoo dot com
Description:
------------
Apache version:2.0.63; PHP version 5.2.10 (.zip); IE 6.0 SP3
I defined a global variable in the beginning of the .php file. It is valid at the beginning of the file, while it becomes invalid at the end of the file. There is no function defined in this .php file.
For the details pls see reproduce code.
Reproduce code:
---------------
All the places this variable is defined or refered are as follows.
line 20: $isloc=$_GET["l"];//Define. It works!
line 31: switch($isloc){...}
line 37: if($isloc!="")
{...
line 109: for($a=1;$a<=$pages;$a++)
line 110: {//for
line 111: if($a!=$gpage)$cmmt1.='<a href=***.php?l='.$isloc.'&id='...'</a> ';////It works!
line 112: else ...
line 113: }//for }//if
line 114: if($isloc!="")echo $isloc;///It becomes null!
line 115: else echo '$isloc is null';
Expected result:
----------------
shows the value of $isloc
Actual result:
--------------
'$isloc is null'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 03:00:01 2025 UTC |
I just tried the test case. The variable works all the time. Still don't know the reason for failure in the big file mentioned before. $isloc='1'; switch($isloc){ case '1':;} $pages=4; if($isloc!="") { for($a=1;$a<=$pages;$a++) {//for if($a!=$page)$cmmt1.='<a href=ad.php?l='.$isloc.'&id=</a> '; else {} }//for }//if if($isloc!=""){echo $isloc;} else {echo '$isloc is null';}