次のコードを実行すると、このエラーが発生します。何故ですか?コールバックの正しい使い方とは?
コード (簡体字)
class NODE {
//...some other stuff
function create($tags, $callback=false) {
$temp = new NODE();
//...code and stuff
if($callback) $callback($temp); //fixed (from !$callback)
return $this;
}
}
$document = new NODE();
$document->create("<p>", function($parent) {
$parent->create("<i>");
});
エラー
Fatal error: Function name must be a string in P:\htdocs\projects\nif\nif.php on line 36