Check if class has method in PHP

后端 未结 4 1401
你的背包
你的背包 2021-02-12 16:04

Currently my code looks like that:

switch ($_POST[\'operation\']) {
    case \'create\':
        $db_manager->create();
        break;
    case \'retrieve\':
         


        
4条回答
  •  感动是毒
    2021-02-12 16:19

    You can use is_callable() or method_exists().

    The difference between them is that the latter wouldn't work for the case, if __call() handles the method call.

提交回复
热议问题