在类内调用该类静态成员和静态方法的前缀修饰,对于非静态成员变量和函数则使用this。
<?php
class StaticExample {
static public $arg1 = "Hello, This is static field.
";
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.