Date: 04/29/98
- Next message: Rasmus Lerdorf: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Previous message: jdavis <email protected>: "[PHP-DEV] Bug #331: static variables in object methods broken"
- In reply to: jdavis <email protected>: "[PHP-DEV] Bug #331: static variables in object methods broken"
- Next in thread: Rasmus Lerdorf: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Reply: Rasmus Lerdorf: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Good call. I can fix static so it would work inside objects, but I think
it's generally a bad idea, as the same static variable would be shared
among all objects of that type. You should really use some property
instead, e.g. $this->a.
I think the best thing would be generating a warning in case static is
declared inside member functions, but I can also make it work like in
regular functions. What do you guys think?
Zeev
At 20:49 29/04/98 -0000, jdavis <email protected> wrote:
>From: jdavis <email protected>
>Operating system: linux
>PHP version: 3.0 Release Candidate 4
>PHP Bug Type: Other
>Bug description:
>sorry if i'm missing something but it would seem that the
>following code should output:
>
>1
>2
>3
>
>instead $a never is set so it doesn't output anyting (except
>the "<p>\n" part)
>
>thank you and pls let me know if you need more info
>-----
>
>class foobar {
>
> function init () {
>
> static $a=1;
>
> print $a;
> print "<p>\n";
>
> $a++;
> }
>};
>
>$bar = new foobar; $bar->init(); $bar->init();
>$bar->init();
>
>
-- Zeev Suraski <zeev <email protected>> For a PGP public key, finger bourbon <email protected>
- Next message: Rasmus Lerdorf: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Previous message: jdavis <email protected>: "[PHP-DEV] Bug #331: static variables in object methods broken"
- In reply to: jdavis <email protected>: "[PHP-DEV] Bug #331: static variables in object methods broken"
- Next in thread: Rasmus Lerdorf: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Reply: Rasmus Lerdorf: "Re: [PHP-DEV] Bug #331: static variables in object methods broken"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

