PHP 根据类名和方法名已面向对象的方式执行函数。

 

 

 

<?php

echo 'testClass';
echo '<br><hr>';

$className = 'TestClass';
$methodName = 'c_out';
$newObj = new $className();
if(method_exists($newObj,$methodName))
{   $newObj ->$methodName(123);
}
else
{
  echo '要调用的方法在对象中不存在';
} class TestClass { public function c_out($a) { echo 'this is c_out'.$a; } } ?>

 

posted @ 2015-04-24 14:54  宁静的天空  阅读(680)  评论(0编辑  收藏  举报