php动态调用方法

<?php
 require_once 'showErrMsg.php';
 $_action = (isset($_REQUEST['action'])?$_REQUEST['action']:"");
 if($_action!=null&&$_action!=''){
  if(function_exists($_action)){
   eval("$_action();"); 
  }else{
   die(showErrMsg ( "<br>当前php文件中不存在方法[<b>".$_action."()</b>]。"));
  }
 }
?>

<?php
 
function showErrMsg($strMsg){
  return "<font color='red'>".$strMsg."</font>";
 }
?>

原文地址:https://www.cnblogs.com/jishu/p/1940135.html