Accept function as parameter in PHP

后端 未结 8 779
Happy的楠姐
Happy的楠姐 2020-11-28 06:22

I\'ve been wondering whether is possible or not to pass a function as parameter in PHP; I want something like when you\'re programming in JS:

object.exampleM         


        
8条回答
  •  无人及你
    2020-11-28 06:59

    Just to add to the others, you can pass a function name:

    function someFunc($a)
    {
        echo $a;
    }
    
    function callFunc($name)
    {
        $name('funky!');
    }
    
    callFunc('someFunc');
    

    This will work in PHP4.

提交回复
热议问题