Re: Strange behaviour of static declared content.
| From: | Joshua Bacher | Date: | Thu, 18 Oct 2007 13:10:57 +0000 |
| Subject: | Re: Strange behaviour of static declared content. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263291@lists.php.net to get a copy of this message | ||
> I can't touch the API.
>
> i have never use static variables inside of functions and likely never will.
> go for static class variables instead :)
>
> <?php
> class foo{
> public static $foobar = false;
> public function bar(){
> static $foobar=false;
> if (self::$foobar === False){
> self::$foobar='FUBeyondAllR';
> echo self::$foobar . "\n";
> }else{echo "already defined\n";}
> }
> }
>
> $f=new foo();
> $f->bar();
> $f->bar();
> foo::$foobar=false;
> $f->bar();
> ?>
>
> nathan@devel ~/working/www/siuConference $ php testScript.php
> FUBeyondAllR
> already defined
> FUBeyondAllR
>
> -nathan
thats the solution for the wrong problem. it's not up to me to change
the API. the API is designed like i noted and i need a way to get around
this behaviour.
thanks for your idea any further suggestions?
josh
--
--------------------------------
joshua bacher
Max Planck Institute for Evolutionary Anthropology
Deutscher Platz 6
04103 LEIPZIG
Germany
web: http://bacher.bash-it.de
--------------------------------