伏地炸毛
2015-03-05 18:03
用zend调试时候怎么出现以下内容了,亲们,求助啊~~~
Parse error: syntax error, unexpected end of file in
D:\xampp\htdocs\test\ImoocMVC02\function.php(28) : eval()'d code on line
1
Fatal error: Call to a member function display() on a
non-object in
D:\xampp\htdocs\test\ImoocMVC02\libs\Controller\testController.class.php on line 8
$testView->display($data);
我估计你在index.php里面也有错,你贴上来看看
问题已经解决,function.php中28行eval('$obj = new '.$name.'View()');应为eval('$obj = new '.$name.'View();');
少加了个分号~~~
testController.class.php
<?php class testController { function show() { $testModel = M ( 'test' ); $data = $testModel->get (); $testView = V ( 'test' ); $testView->display ( data ); } }
function.php
<?php function C($name, $method) { require_once '/libs/Controller/' . $name . 'Controller.class.php'; // $testController = new testController(); // $testController->show(); eval ( '$obj = new ' . $name . 'Controller();$obj->' . $method . '();' ); } // C('test','show'); function M($name){ require_once '/libs/Model/'.$name.'Model.class.php'; eval('$obj = new '.$name.'Model();'); return $obj; /* * eval()函数调用简单但是不安全 * eval('$obj = new '.$name.'Model();'); * 可以用下面的代码代替 * $model = $name.'Model'; * $obj = new $model; * */ } function V($name){ require_once '/libs/View/'.$name.'View.class.php'; eval('$obj = new '.$name.'View()'); return $obj; } /* 对非法字符进行转义 */ function daddslashes($str){ //get_magic_quotes_gpc()判断魔法符号的打开状态 //addslashes()对特殊符号进行转义 return (!get_magic_quotes_gpc())?addslashes($str):$str; }
MVC架构模式分析与设计
82396 学习 · 929 问题
相似问题