测试function_exist与is_callable

is_callable

查看静态方法是否能调用

<?php
  
     class test {
         static  function a() {
        	echo "test";
          }

          protected static function b() {
              echo  "test";
          }

          private static function c() {
              echo "test";
          }
      }

	class abc {
          public function chech_is_callable($Object,$funcName){
              var_dump( is_callable(array($Object,$funcName)));
              //此处array($object,$funcname)的用法,相当于$object::$funcname调用$object的$funcname方法

          }
      }

      $abc=new abc();
      $abc->chech_is_callable("test","a");//true
      $abc->chech_is_callable("test","b");//false
      $abc->chech_is_callable("test","c");//false
?>

function_exists

验证函数是否存在

<?php
  
    function check_function_exists()
    {
        echo 111;
    }

    var_dump(function_exists("check_function_exists")); //true
    var_dump(function_exists("function"));  //false
Licensed under 京ICP备17003353号-3