If I have a static variable declared within a (non-static) member function of a class, is it static to each instance of that class, or static across all instances? Sorry if the answer should be obvious, I can’t find it anywhere.
EDIT:
I have accepted zerkms’s answer, 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
http://ideone.com/Cq2s6