[wp-hackers] Re: 2.0.10 and 2.1.3 Release Candidates
Sabin Iacob
iacobs at m0n5t3r.info
Sun Mar 18 01:04:59 GMT 2007
Robin Adrianse wrote:
> Does PHP 4 have support for the static and self keywords?
>
> On 3/17/07, Sabin Iacob <iacobs at m0n5t3r.info> wrote:
static yes, self no; and static is supported only in function scope, not
in class scope; so, to store something statically in a class (instead of
making it global, for instance), you would need to to something like this:
class aaa {
function &bbb(){
static $_kk;
if(!isset($_kk)){
$_kk = "";
}
return $_kk;
}
}
$kk = &aaa::bbb();
echo var_export($kk, true), "\n";
$kk .= "asdfasfasfdasfd";
echo var_export(aaa::bbb(), true), "\n";
which outputs
''
'asdfasfasfdasfd'
More information about the wp-hackers
mailing list