If I have a static variable declared inside a (non-static) member function of a class, is it static for every instance of this class or static in all instances? Sorry if the answer should be obvious, I can't find anything.
EDIT:
I accepted the answer by zerkms, but here is another example:
<?php
class X {
public function fun($bar) {
static $foo = null;
if ($foo != null) print $foo . "<br/>";
$foo = $bar;
}
}
$x1 = new X();
$x1->fun(42);
$x2 = new X();
$x2->fun(123);
$x2->fun(666);
?>
Output:
42
123
source
share