[php] 實作callback

用名稱呼

function run1($callback)
{
 $callback('123');
}

function funA($val)
{
 echo 'funA:'.$val;
}

run1('by run1');//funA:by run1

用物件傳(推薦)
class ClassB
{
 public function funB($val){
  echo 'ClassB:funB:'.$val;
 }
}

function run2(ClassB $callable){
 $callable->funB('by run2');
}

run2(new ClassB());//ClassB:funB:by run2
Next: [Android] setClickListener in custom view Prev: [Mac] 解決 您要讓應用程式 XXX 接受傳入的網路連接嗎 一直跳出