类内部使用 self::字段
外部使用 类名::字段
<?phpclassStaticTest{publicstatic$data =0;
publicfunctionappend() {//类内部访问静态方法或属性 使用self:://在其他语言中 一般是直接$data++;self::$data++;
}
}
$p = new StaticTest();
$p->append();
$p2 = new StaticTest();
$p2->append();
//外部访问类中的静态方法或属性 类名::字段echo StaticTest::$data;//2?>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了 PHP入门7 静态属性的访问,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。










