大家好,小弟初识zf有些地方还不太明白:比如我写一个form的时候(用的工具是ZDE),$form=new Zend_form(); 写上这句话以后为什么还要 在前面加上require_once 'Zend/form.php';才行呢?我在网上看别人写的东西都不用require,这是怎么回事呢?是不是我哪的配置不正确?
还有一段代码
class IndexController extends Zend_Controller_Action
{
    function indexAction()
    {
        $this->view->pageTitle = "Zend_Form Example";
        $this->view->bodyCopy = "<p >Please fill out this form.</p>";    }
}
里面的$this->view 是从哪来的呢?我自己试着写了一下,this完之后没有view这个东西啊,不太明白,还请高人指点一二,谢谢

解决方案 »

  1.   

    网上的东西不过是个例子,
    Zend_form类定义在Zend/form.php之中,
    所以必须以某种方法require。$this->view是Zend_Controller_Action中的属性,
    是一个Zend_View_Interface接口的实例。
    如果你什么都不做的话,应该有一个默认Zend_View_Interface,
    $this->view可以直接调用。
    建议lz看看官方的手册:http://framework.zend.com/manual/zh/index.html
      

  2.   

    楼主在网上看的只是部分的代码,zend框架也只是一些代码而已,用到哪个,都要 include 或require一下进来的。
    你的$this->view是在Zend_Controller_Action定义的,具体你可以看一下定义的那个类最重要的是好好查看手册
      

  3.   

    如果怕麻烦~ 你可以在 index.php 或者 app.php include近来的阿~ 实际上这也没有什么麻烦的~ 不就以行代码吗 这样还更灵活~
      

  4.   

    阅读:
    http://ca.php.net/manual/en/language.oop5.autoload.php
    http://framework.zend.com/docs/quickstart