In PHP, how do I check if a function exists?

后端 未结 6 1107
挽巷
挽巷 2020-11-30 11:00

How can I check if the function my_function already exists in PHP?

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 11:27

    Checking Multiple function_exists

    $arrFun = array('fun1','fun2','fun3');
    if(is_array($arrFun)){
      $arrMsg = array();
      foreach ($arrFun as $key => $value) {
        if(!function_exists($value)){
          $arrMsg[] = $value;
        }
      }
      foreach ($arrMsg as $key => $value) {
        echo "{$value} function does not exist 
    "; } } function fun1(){ } Output fun2 function does not exist fun3 function does not exist

提交回复
热议问题