#26173 [Com]: Global vs function scope problem?
| From: | kharris at lhinfo dot com | Date: | Wed, 26 Nov 2003 18:16:55 +0000 |
| Subject: | #26173 [Com]: Global vs function scope problem? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51115@lists.php.net to get a copy of this message | ||
ID: 26173
Comment by: kharris at lhinfo dot com
Reported By: myle34 at hotmail dot com
Status: Bogus
Bug Type: Variables related
Operating System: Windows XP Home
PHP Version: 5.0.0b2 (beta2)
New Comment:
I have a similar problem and here is the code I used to track it:
cfg file
<?php
$gPlace = "http://www.lhinfo.com";
?>
run file
<?php
include ( 'cfgfile.inc' );
echo 'global space [' . $gPlace .];
function testme ()
{
global $gPlace;
echo 'testme [' . $gPlace . ']';
}
testme ();
Ouput:
global space [http://www.lhinfo.com]
testme []
I have even changed it to remove the config file and place the globals
at the top of my file. The same problem occurs.
Dumping $GLOBALS shows gPlace as a null string
Previous Comments:
------------------------------------------------------------------------
[2003-11-08 01:53:32] myle34 at hotmail dot com
Sorry, bad reporduce code....
------------------------------------------------------------------------
[2003-11-08 01:52:20] myle34 at hotmail dot com
sorry, forgot to call Test() at the bottom of the reproduce code...
simply put in Test(); at the bottom.
------------------------------------------------------------------------
[2003-11-08 01:49:16] myle34 at hotmail dot com
Description:
------------
I'm not sure if this is a bug, but I haven't found anything so far
stating that it isn't so...
I am using Windows XP Home and Apache 2.0.47 with PHP beta 2.
Reproduce code:
---------------
// Uncommenting the following makes it work...
// global $foo;
$foo = 'bar';
// Uncommenting the following doesn't help...
// global $foo;
function Test()
{
global $foo;
echo $foo;
}
Expected result:
----------------
bar
Actual result:
--------------
No output
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26173&edit=1