<?php
class classname
{
public $attribute;
function __get($name)
{
return 'here:'.$this->$name;
}
function __set ($name, $value)
{
$this->$name = $value;
}
}
$a = new classname();
$a->attribute = 5;
echo $a->attribute;
上記のスクリプトを実行すると、次のように表示されます:5
質問:
echo $a->attribute;
このコード行は を呼び出しfunction __get($name)
ますよね? なぜ表示されないのhere:5
ですか?