Bug #61651 [Opn]: Inexplicable double result with global var in a function
| From: | laruence@php.net | Date: | Sat, 07 Apr 2012 15:03:03 +0000 |
| Subject: | Bug #61651 [Opn]: Inexplicable double result with global var in a function | ||
| References: | 1 | Groups: | php.webmaster |
| Request: | Send a blank email to php-webmaster+get-13338@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61651&edit=1
ID: 61651
Updated by: laruence@php.net
Reported by: valerio dot bozzolan at gmail dot com
Summary: Inexplicable double result with global var in a
function
Status: Open
Type: Bug
Package: Website problem
Operating System: Linux
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
I can not reproduce it.....
Previous Comments:
------------------------------------------------------------------------
[2012-04-06 14:06:21] nikic@php.net
I'm not sure whether or not I got you right: Are you saying that you have two files, with
exactly the same content, but they are behaving differently?
------------------------------------------------------------------------
[2012-04-06 13:47:46] valerio dot bozzolan at gmail dot com
Description:
------------
I already know that nobody in the world will give me an answer, because in a clean file this code
works but in the queue of another file it does not work, even if the code of the queue of the second
file (which does not work) is exactly identical to what I ran in the first clean file.
Var "$a", in the function of my first file, is normal out of the function, and normal in
the function.
Same code in the queue of my second file give me a different result: "$a" is normal out of
the funcion, but in the function IS NULL!
(Excuse my English)
Test script:
---------------
unset($a);
$a = "PIPPO";
function foo()
{
global $a;
echo "In function: ";
var_dump($a);
}
echo "Out function: ";
var_dump($a);
echo "<br />";
foo();
Expected result:
----------------
First clean file result:
Out function: string(5) "PIPPO"
In function: string(5) "PIPPO"
Second file result:
Out function: string(5) "PIPPO"
In function: string(5) "PIPPO"
Actual result:
--------------
First clean file result:
Out function: string(5) "PIPPO"
In function: string(5) "PIPPO"
Second file result (inexplicable):
Out function: string(5) "PIPPO"
In function: NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61651&edit=1