示例代码出错

#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 671

Fatal 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

#3 jake

已经修正bug,请重新下载框架代码。抱歉

2017-01-03 17:53:11

#4 jake

有发现疑似bug,明天修正,抱歉。

2017-01-03 17:53:18

#5 liguangping

楼主问题解决了吗  咨询解决办法

2017-02-05 19:02:49

#6 jake

liguangping 发表于 2017-2-5 19:02
楼主问题解决了吗  咨询解决办法
重新下载框架代码即可

2017-02-08 08:52:16