|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-04-01 21:26 UTC] tpunt@php.net
-Status: Open
+Status: Wont fix
[2017-04-01 21:26 UTC] tpunt@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 21:00:01 2025 UTC |
Description: ------------ Dear Sirs, It seems that there is a serious Variable Scope bug when PHP ( v5.2 ) Scripts are executed in the ActivePHP Environment. The problem is as follows: # 1 -- when a Variable is declared in Global Scope Statements without explicit use of the "$GLOBALS" Array, it not really becomes Global and can't be seen within Functions through the "global" Keyword nor "$GLOBALS"; # 2 -- conversely, a Variable declared with explicit use of "$GLOBALS" in Global Scope Statements can be seen within Functions, but isn't visible for the own Global Scope Statements ( it's required use of "$GLOBALS"... This also occurs when the declaration is done within a Function -- through "$GLOBALS" ). I have employed a "php5activescript.dll" version 5.2.0.0 ( 53.314bytes. It's that one distributed with the "pecl-5.2.0-Win32.zip" package ) on Windows 9x and XP. Reproduce code: --------------- function varsGlbTest() { global $varGlb0, $varGlb1; /*######*/ $WScript->Echo("varsGlbTest() -- varGlb0= '".$varGlb0."'"); /*######*/ $WScript->Echo("varsGlbTest() -- \$GLOBALS['varGlb0']= '".$GLOBALS["varGlb0"]."'"); /*######*/ $WScript->Echo("varsGlbTest() -- varGlb1= '".$varGlb1."'"); $GLOBALS["varGlb2"]="[varGlb2]"; global $varGlb2; /*######*/ $WScript->Echo("varsGlbTest() -- varGlb2= '".$varGlb2."'"); } $varGlb0="[varGlb0]"; $GLOBALS["varGlb1"]="[varGlb1]"; /*######*/ $WScript->Echo("[global] -- varGlb0= '".$varGlb0."'"); /*######*/ $WScript->Echo("[global] -- varGlb1= '".$varGlb1."'"); /*######*/ $WScript->Echo("[global] -- \$GLOBALS['varGlb1']= '".$GLOBALS["varGlb1"]."'"); varsGlbTest(); /*######*/ $WScript->Echo("[global] -- varGlb2= '".$varGlb2."'"); /*######*/ $WScript->Echo("[global] -- \$GLOBALS['varGlb2']= '".$GLOBALS["varGlb2"]."'"); Expected result: ---------------- The output should be the following: # [global] -- varGlb0= '[varGlb0]' # [global] -- varGlb1= '[varGlb1]' # [global] -- $GLOBALS['varGlb1']= '[varGlb1]' # varsGlbTest() -- varGlb0= '[varGlb0]' # varsGlbTest() -- $GLOBALS['varGlb0']= '[varGlb0]' # varsGlbTest() -- varGlb1= '[varGlb1]' # varsGlbTest() -- varGlb2= '[varGlb2]' # [global] -- varGlb2= '[varGlb2]' # [global] -- $GLOBALS['varGlb2']= '[varGlb2]' Actual result: -------------- The observed output is the following: # [global] -- varGlb0= '[varGlb0]' # [global] -- varGlb1= '' ( "varGlb1" is NULL ( it was not yet assigned ) ) # [global] -- $GLOBALS['varGlb1']= '[varGlb1]' ( ?!... ) # varsGlbTest() -- varGlb0= '' ( "varGlb0" is NULL ( has been it assigned to NULL?... ) ) # varsGlbTest() -- $GLOBALS['varGlb0']= '' ( [idem] ) # varsGlbTest() -- varGlb1= '[varGlb1]' # varsGlbTest() -- varGlb2= '[varGlb2]' # [global] -- varGlb2= '' ( "varGlb2" is NULL ( it was not yet assigned ) ) # [global] -- $GLOBALS['varGlb2']= '[varGlb2]' ( ?!... )