这段代码与普通的php一起工作正常:
<?php
function barber($type)
{
echo "You wanted a $type haircut, no problem\n";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
?>
如何在Zend控制器的Action中实现相同的东西? (我相信Zend不会允许在引号中调用函数而 $ this 和 self 在这件事上是不可能的)
答案 0 :(得分:4)
在控制器中创建一个方法,例如
private function foo($var) {
return $var++;
}
使用call_user_func()
call_user_func(array($this, 'foo'), $a);