> >>> 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? > > > >In that case you need a new foo. That's the only way you're going to > >reset the internal static if the API doesn't give you a way to do it. > > > >$f=new foo(); > >$f->bar(); > >$f->bar(); > >$g=new foo(); > >$g->bar(); > > Actually, scratch that, won't work. Not even unsetting $f before > creating the new object works. This kinda sucks since it means PHP does > not support static function-scoped vars. > > I think you're out of luck. You need to find a way to override this > behaviour. Can you not add a function to the API to reset that static? > That wouldn't break the existing contract but would let you do what you > need. > to be honest i meanwhile have a workaround. i could suppress the call of the function for the first time and therefore suppressed the initializing of $foobar. now it is only running at the time i need it, with the parameters that i want it to run with. For me it's just a question of interest. At least, i would say, php behaves somehow uncool in this situation. But on the other hand it can also be a nice feature if you want a variable just to be initialized once and protect it afterwards from arbitrary access. i am unsure how to feel about it. if you want a protected variable why don't you declare it as protected? i thank you very much for all you suggestions. maybe it's a good thing to ask for this as a feature request. thank you all josh -- -------------------------------- joshua bacher Max Planck Institute for Evolutionary Anthropology Deutscher Platz 6 04103 LEIPZIG Germany web: http://bacher.bash-it.de -------------------------------- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php