#23150 [NEW]: Using global $x, while $x is already global behaves in an inconsistent way
| From: | arattink at correct dot net | Date: | Thu, 10 Apr 2003 14:20:33 +0000 |
| Subject: | #23150 [NEW]: Using global $x, while $x is already global behaves in an inconsistent way | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-37523@lists.php.net to get a copy of this message | ||
From: arattink at correct dot net
Operating system: Linux 2.4.16-4GB-SMP
PHP version: 4.3.1
PHP Bug Type: Scripting Engine problem
Bug description: Using global $x, while $x is already global behaves in an inconsistent way
I would expect that using $x1->f = 1234; would work the
same if $x1 is declared explicitely as global or not, if
it is already global, but:
<?
class X
{
var $f = 'PHP sucks';
};
$x1 = new X;
$x2 = new X;
$z1 = &$x1;
$z2 = &$x2;
{
global $x1;
$x1->f = 'PHP is OK!';
}
{
$x2->f = 'PHP is OK!';
}
echo "x1.f=".$x1->f."\n";
echo "x2.f=".$x2->f."\n";
echo "z1.f=".$z1->f."\n";
echo "z2.f=".$z2->f."\n";
?>
shows this is not true. It seems that $z1 loses its
reference to $x1, even though $x1 is never reassigned.
Tested on php 4.2.2 and php 4.3.1, same results.
List of modules: does not apply to this problem.
Known workaround: don't do this... However, it can easily
happen by mistake (as it did in our case).
Yours sincerely,
Arnoud Rattink.
--
Edit bug report at http://bugs.php.net/?id=23150&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23150&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23150&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23150&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23150&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23150&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23150&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23150&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23150&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23150&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23150&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23150&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23150&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23150&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23150&r=gnused