PHP pass function name as param then call the function?

前端 未结 7 1670
感动是毒
感动是毒 2020-11-29 03:58

I need to pass a function as a parameter to another function and then call the passed function from within the function...This is probably easier for me to explain in code..

相关标签:
7条回答
  • 2020-11-29 04:38

    In php this is very simple.

    <?php
    
    function here() {
      print 'here';
    }
    
    
    function dynamo($name) {
     $name();
    }
    
    //Will work
    dynamo('here');
    //Will fail
    dynamo('not_here');
    
    0 讨论(0)
提交回复
热议问题