PHP 4.0 Bug #4552: references inside functions work with GLOBALS, not global

From: Date: Tue, 23 May 2000 00:23:52 +0000
Subject: PHP 4.0 Bug #4552: references inside functions work with GLOBALS, not global
Groups: php.dev 
Request: Send a blank email to php-dev+get-19263@lists.php.net to get a copy of this message
From: bill@rsv.ricoh.com Operating system: RH Linux 2.2.12-20 PHP version: 4.0 Release Candidate 2 PHP Bug Type: Scripting Engine problem Bug description: references inside functions work with GLOBALS, not global // Bug-script for assigning references for global variables inside functions $fruit = "apple"; $rock = "granite"; function twiddle(){ global $fruit, $rock; $fruit = &$rock; $GLOBALS["rock"] = &$GLOBALS["fruit"]; // the "global" command works here echo "inside : fruit=$fruit rock=$rock<br>\n"; } echo "BEFORE: fruit=$fruit rock=$rock<br>"; twiddle(); echo "AFTER: fruit=$fruit rock=$rock"; // But only the reassignment using GLOBALS has an effect outside // the function; the "global" assignment persists only inside. ---------------- PHP configured with mysql ; otherwise plain vanilla.

« previous php.dev (#19263) next »