Re: Functions with Static Variables vs. Classes
| From: | news_yodpeirs at thoftware dot de | Date: | Thu, 29 Nov 2007 13:48:26 +0000 |
| Subject: | Re: Functions with Static Variables vs. Classes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265225@lists.php.net to get a copy of this message | ||
From: "Zoltán Németh" <znemeth@alterationx.hu>
>> function example($elem='') {
>> static $store = array();
>
> AFAIK the above line should cause an error on the second run of the
> function, as you declare the same static variable for the second time.
>
> or am I wrong?
I think so - otherwise static Variables would be quite senseless. The line
starting with static is (so do I think) once evaluated at compile-time or at
the first run and the ignored.
Thomas