self

在类内调用该类静态成员和静态方法的前缀修饰,对于非静态成员变量和函数则使用this。

<?php
class StaticExample {
    static public $arg1 = "Hello, This is static field.\n";
    static public function sayHello() {
        print self::$arg1;
    }
}

print StaticExample::$arg1;
StaticExample::sayHello();

结果:

Stephens-Air:Desktop$ php Test.php

Hello, This is static field.

Hello, This is static field.

posted @ 2017-07-23 21:47  摩丿羯  阅读(148)  评论(0编辑  收藏  举报