当前位置:Gxlcms > PHP教程 > PHP入门7静态属性的访问

PHP入门7静态属性的访问

时间:2021-07-01 10:21:17 帮助过:28人阅读

类内部使用 self::字段
外部使用 类名::字段

classStaticTest{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 <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介绍了 PHP入门7 静态属性的访问,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

  • 人气教程排行