為什么顯示找不到方法
function 中:
?function C($name,$method){
? ? ? require_once ($name.'Controller.class.php');?
// eval('$obj=new'.$name.'Controller;$obj->'.$method.'();');
? ?$controller=$name.'Controller';
$obj=new $controller();
$obj->method();
? ? }
index中:
<?php
//url形式 index.php?controller=控制器名&method=方法名;
?require_once ('function.php');
?$controllerAllow=array('test','index','show');
?$methodAllow=array('test','index','show');
?$controller=in_array($_GET['controller'],$controllerAllow)?daddslashes($_GET['controller']):'index';
$method=in_array($_GET['method'],$methodAllow)?daddslashes($_GET['method']):'index';
$a=C($controller, $method);
?echo $a;
? ??>
文件都在同級(jí)目錄
顯示錯(cuò)誤:
Fatal error: Uncaught Error: Call to undefined method testController::method() in D:\UPUPW_AP7.0\htdocs\MVC\function.php on line?7
( ! )?Error: Call to undefined method testController::method() in D:\UPUPW_AP7.0\htdocs\MVC\function.php on line?7
Call Stack
求解決
2017-01-19
$obj->method(); 這里少了個(gè)$