view为空,输出不了,为什么?
index.php
require_once('function.php');
require_once('config.php');
//对smarty初始化
$view=ORG('Smarty/','Smarty',$viewconfig);
//设置允许的控制器名和方法名数组
$controllerAllow=array('test','index');
$methodAllow=array('test','index','show');
//in_array函数作用:判断一下这个字符串是否存在于字符串里
$controller=in_array($_GET['controller'],$controllerAllow)?daddslashes($_GET['controller']):'index';
$method=in_array($_GET['method'],$methodAllow)?daddslashes($_GET['method']):'index';
C($controller,$method);
testController
class testController{
function show(){
global $view;
$testModel = M('test');
$data=$testModel->get();
var_dump($view);
$view->assign('str','哈哈哈');
$view->display('test.tpl');
}
}
提示出错:Call to a member function assign() on a non-object