Check if class has method in PHP

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

Currently my code looks like that:

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


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-12 16:31

    You can use method_exists(). But this is a really bad idea

    If $_POST['operation'] is set to some magic function names (like __set()), your code will still explode. Better use an array of allowed function names.

提交回复
热议问题