简体   繁体   中英

user defined function in zend framework

This piece of code is working fine with normal php:

<?php
function barber($type)
{
    echo "You wanted a $type haircut, no problem\n";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
?>

How do i implement the same stuff with in an Action of a Zend controller ? (I believe Zend wont allow to call a function with in quotes and $this and self are not possible in this matter)

Create a method in your controller, eg

private function foo($var) {
    return $var++;
}

Call it like this using call_user_func()

call_user_func(array($this, 'foo'), $a);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM