<?php
class c1
{
public static function f1()
{
return "hello";
}
public static $a=10;
public function f2()
{
echo $this->f1(); //prints "hello"
echo $this->a;//ERROR:Undefined property: c1::$a in C:\wamp\www\class_in_php\example5.php on line 14
}
}
$obj1=new c1;
$obj1->f2();
?>
$this またはそのクラスのオブジェクトを使用してクラスの静的変数にアクセスできないのはなぜですか? しかし、$this またはそのクラスのオブジェクトを使用して、そのクラスの静的関数にアクセスできます。
このような現象の背後にある理由は何ですか?