Bug #61651 [NEW]: Inexplicable double result with global var in a function
| From: | valerio dot bozzolan at gmail dot com | Date: | Fri, 06 Apr 2012 13:47:46 +0000 |
| Subject: | Bug #61651 [NEW]: Inexplicable double result with global var in a function | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-13335@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.3.10
Package: Website problem
Bug Type: Bug
Bug description:Inexplicable double result with global var in a function
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 bug report at https://bugs.php.net/bug.php?id=61651&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61651&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61651&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61651&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=61651&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61651&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=61651&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=61651&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=61651&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=61651&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=61651&r=support
Expected behavior: https://bugs.php.net/fix.php?id=61651&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=61651&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=61651&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=61651&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61651&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61651&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=61651&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=61651&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=61651&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=61651&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=61651&r=mysqlcfg