php - static in class declaration vs static in function -


class a{    static $var = true;    function f(){    }  } 

vs

class a{    function f(){     static $var = true;    } } 

there doesn't seem difference. there advantages of using 1 on other?

note $var used in f() function only. understand declaring in class header required if variable needs used in multiple functions

in later example may use var inside f function. other accessible anywhere inside class a::var or outside a::var


Comments