call function dynamically, passing arguments from variable
问题 here is my ajax_handle file: if ($_SERVER['HTTP_X_REQUESTED_WITH'] !== "XMLHttpRequest") { echo "Error"; exit(); } $req = explode("_",$_POST['req']); $className = $req[0] . "Controller" ; $methodName = $req[1]; $file = "application/controllers/" . $className . ".php" ; require_once $file; if ($_POST['data']) { var_dump($_POST['data']); } $controller = new $className; $result = $controller->$methodName(); echo json_encode($result); I send the arguments as any array in the $_POST['data']