php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49319 Global variable is valid in the beginning of .php, which is invalid at the end.
Submitted: 2009-08-21 09:59 UTC Modified: 2009-08-29 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: yippaolo at yahoo dot com Assigned:
Status: No Feedback Package: Variables related
PHP Version: 5.2.10 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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>&nbsp;';////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'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-21 10:01 UTC] pajoye@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2009-08-21 10:10 UTC] yippaolo at yahoo dot com
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>&nbsp;';
	else {}		
	}//for  
}//if  
if($isloc!=""){echo $isloc;}
else {echo '$isloc is null';}
 [2009-08-21 10:15 UTC] pajoye@php.net
The variable is certainly being set somewhere in the big script.

I set this bug back to feedback, pls reopen it only when you have a way to reproduce your problem, or tell us if you can't (will then bogus this report).
 [2009-08-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Dec 07 00:03:49 2021 UTC