#1 huxinwei
ApacheFriends XAMPP Version 1.8.1
+ Apache 2.4.3
+ MySQL 5.5.27 (Community Server)
+ PHP 5.4.7 (VC9 X86 32bit thread safe) + PEAR
框架使用3.1,导入教程中
guestbook6[1].rar访问locahost/guestbook错误:
Notice: Undefined property: Smarty::$engine in F:\xampp\htdocs\guestbook\speedphp\Drivers\Smarty\Smarty.class.php on line 671Fatal error: Call to a member function assign() on a non-object in F:\xampp\htdocs\guestbook\speedphp\Core\spController.php on line 89
数据库配置检查没有问题,环境设置检查也没有问题。控制器代码没有更改过。没有覆盖构造函数。
2017-01-03 15:49:01
#2 huxinwei
index.php:
define("SP_PATH",dirname(__FILE__)."/SpeedPHP");
define("APP_PATH",dirname(__FILE__));
$spConfig = array(
"db" => array(
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'test',
),
'view' => array(
'enabled' => TRUE, // 开启视图
'config' =>array(
'template_dir' => APP_PATH.'/tpl', // 模板目录
'compile_dir' => APP_PATH.'/tmp', // 编译目录
'cache_dir' => APP_PATH.'/tmp', // 缓存目录
'left_delimiter' => '<{', // smarty左限定符
'right_delimiter' => '}>', // smarty右限定符
),
)
);
require(SP_PATH."/SpeedPHP.php");
spRun(); // SpeedPHP 3新特性
main.php:
class main extends spController
{
function index(){ // 这里是首页
$guestbook = spClass("guestbook");
$this->results = $guestbook->findAll(); // 用$this->results可以将$guestbook->findAll()的值发送到模板上面,模板上可以用$results来使用该值。
$this->display("white/index.html"); // 显示模板,这里使用的模板是根目录/tpl/green/index.html。
}
function write(){ // 这里是留言
$guestbook = spClass("guestbook");
$newrow = array( // 这里制作新增记录的值
'name' => $this->spArgs('name'),
'title' => $this->spArgs('title'), // 从spArgs获取到表单提交上来的title
'contents' => $this->spArgs('contents'),
);
$guestbook->create($newrow);
echo "留言成功,
返回";
}
}
2017-01-03 15:53:53