#43600 [Opn]: static array

From: Date: Sat, 15 Dec 2007 01:06:37 +0000
Subject: #43600 [Opn]: static array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120663@lists.php.net to get a copy of this message
ID: 43600 Updated by: felipe@php.net Reported By: 6eWmA67gxAebq at jeanpierredaviau dot com Status: Open Bug Type: Output Control Operating System: win xp PHP Version: 5.2CVS-2007-12-14 (snap) New Comment: Clarifying example: <?php class foo { static $foo = array(); static function test($obj) { self::$foo[] = $obj; } } class bar { public function __construct() { foo::test($this); } } $a = new bar; unset($a); var_dump(foo::$foo); // He expects empty array ?> Previous Comments: ------------------------------------------------------------------------ [2007-12-14 21:23:39] 6eWmA67gxAebq at jeanpierredaviau dot com Description: ------------ a static array dont retain a modification PHP 5.2.2 (cli) (built: May 2 2007 19:18:26) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with DBG v2.15.5, (C) 2000,2007, by Dmitri Dmitrienko Reproduce code: --------------- http://groups.google.com/group/alt.comp.lang.php/msg/79060a6a7c4c806e Expected result: ---------------- print_r (Registre::getRegistre()); Array ( [0] => info2 Object ( [var] => 0 [class] => info2 ) ) Actual result: -------------- $a = new info(); $b = new info2(); $a = NULL; print_r (Registre::getRegistre()); //dont print the changed self::$leRegistre Array ( [0] => info Object ( [var] => 0 [class] => info ) [1] => info2 Object ( [var] => 0 [class] => info2 ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43600&edit=1

« previous php.bugs (#120663) next »