2011-04-05 30 views
0

我是zend框架的新手。我在bootstrap文件中找到如下代碼。

 
protected function _initDoctype() 
    { 
     $this->bootstrap('view'); 
     $view = $this->getResource('view'); 
     $view->doctype('XHTML1_STRICT'); 
    } 

任何人都可以給我解釋一下什麼是 「$這個 - >引導( '查看');」 這是什麼意思?

回答

1

這是非常簡單的,它從字面上看是bootstraps的View對象。
自引導是您設置(配置和實例化)對象,解決依賴關係等的一個步驟。
完成此操作是因爲必須先設置查看對象才能設置Doctype。

3

它設置視圖資源,以便您可以訪問它。沒有它,下面的線不會返回任何把在$視圖變量,你會得到錯誤:

Fatal error: Call to a member function doctype() on a non-object. 
4

從您的片段來了same page

Now that we have a view, let's flesh out our _initDoctype() method. In it, we will first ensure the View resource has run, fetch the view object, and then configure it.