【发布时间】:2011-12-30 05:08:11
【问题描述】:
在复杂应用程序中创建了我自己的 MVC 框架后,我有一个问题。 我动态执行这样的函数:
<?php
class dyn {
public function do_me() {
echo "hello";
}
public function execute_other_method($var = 0) {
if ($var != 0 && method_exists($this, $var)) {
$this->$var();
}
}
}
$do_method = "do_me"; // this variable is usually from GET or POST, it's dynamically set anyway
$class = new dyn;
$class->execute_other_method($do_method); // echoes hello
?>
这完美无缺,但我的问题是:它有什么缺点吗?
如果我能改进这种执行方法,我很乐意这样做。
现在我在作为服务器的本地 PC 上执行复杂网页的平均时间为 0.0080s ~ 0.0150s,最大时间为 0.0300s(网页包括数据库查询、preg_match/replace、计算等)。
【问题讨论】:
标签: php model-view-controller oop