php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39597 ActivePHP - Variable Scope Bug
Submitted: 2006-11-22 22:45 UTC Modified: 2006-11-22 23:29 UTC
From: marcus3v at hotmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.0 OS: Windows 9x/XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marcus3v at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-11-22 22:45 UTC] marcus3v at hotmail dot com
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.

# Obs.: since this is a PECL issue, it should be posted on the PECL Bug Tracking System. It was also posted there... I have posted here because it appears that this extension ( ActivePHP ) have been a little "abandoned": on "pecl.php.net", the link to the latest package is broken; the only actual source for the compiled DLL is "pecl4win.php.net"... Thus, by the way of the uncertainty, I have posted here ( maybe you have some direct and special contact with the extension's developer... ).

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]' ( ?!... )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-22 23:00 UTC] tony2001@php.net
>I have posted here because it appears that this extension >( ActivePHP ) have been a little "abandoned".

That doesn't mean you should report this issue twice.
Abandoned means abandoned. You can try to contact the author directly and if that doesn't help - we can't help you, sorry.
 [2006-11-22 23:29 UTC] marcus3v at hotmail dot com
Well, Tony, it's fine...

But I thought that ActivePHP was a more ( and should be... ) important thing to the PHP Group ( let's remember that ActiveScript is one of the most interesting things ( few things ) that MS has yet made in the Windows development ground -- and, with the PHP Win32API extension, becomes an extraordinarily powerfull one ) and, thus, deserved some sort of "differentiated" attention... It was a bad thought...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 12:01:33 2025 UTC