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>";
 }
?>

posted @ 2008-12-17 17:23  ljlxyf  阅读(377)  评论(0编辑  收藏  举报