確定我有以下在PHP中存儲一個閉合功能的類屬性
<?php
class foo{
public $bar = NULL;
public function boo(){
$this->bar();
}
}
$mee = new foo();
//save a closure function on the property
$mee->bar = function(){
echo 'hahaha';
};
//invoke the closure function by using a class method
$mee->boo();
?>
的代碼,你可以看到它運行在這裏http://codepad.org/s1jhi7cv
現在我想在這裏什麼是存儲閉合功能在類方法上。
以及閉包是儘可能我讀到它的文檔在這裏http://php.net/manual/en/functions.anonymous.php
這可能嗎?我錯了嗎?請糾正我
你不應該爲此使用「codepad.org」,他們正在使用一個尚未支持閉包的漂亮舊版本的PHP。 – Niko