Bug or undocumented feature: static?

From: Date: Tue, 22 May 2001 10:13:28 +0000
Subject: Bug or undocumented feature: static?
Groups: php.dev 
Request: Send a blank email to php-dev+get-56228@lists.php.net to get a copy of this message
Hi, I stepped into something yesterday I would call an undocumented feature or a bug, don't know if I should make a bug report. Here's the snippet: function bar() { static $j = 0; print ++$j; } class foo { function foo() { static $i = 0; print ++$i; } function bar() { static $j = 0; print ++$j; } } $obj1 = new foo(); => prints 1 $obj2 = new foo(); => prints 2 $obj1->bar(); => prints 1 $obj2->bar(); => prints 2 bar(); => prints 1 Looks like the static variable is not bound to the member functions of my objects. I expected that member functions from different objects of the same type do not share static variables, so that the output would be "11111". Ulf -- NetUSE AG Dr.-Hell-Straße Fon: +49 431 386 436 00 http://www.netuse.de/ D-24107 Kiel Fax: +49 431 386 435 99 PHP lernen? Noch sind Schulungsplätze frei: http://www.netuse.de/

« previous php.dev (#56228) next »