これは、プロパティ「質問」に割り当てられた文字列を返すメソッドを持つ単純なクラスです。メソッド出力から返されたプロパティ値を出力しないのはなぜですか?
エラーメッセージは表示されません。表示されるのは「Here is:」だけですが、プロパティの値がありません:(
class DisplayQuestion {
public $question;
function __construct ($question){
$this->question = $question;
}
function output(){
echo "<p>Here is: $this->question</p>";
}
}
$test = new DisplayQuestion("What's your question?");
$test->output();