Php 试图理解zend框架中的一些代码
project/index.phpPhp 试图理解zend框架中的一些代码,php,zend-framework,Php,Zend Framework,project/index.php <?php error_reporting(E_ALL|E_STRICT); date_default_timezone_set('Europe/London'); set_include_path('.' . PATH_SEPARATOR . './library' . PATH_SEPARATOR . './application/models/' . PATH_SEPARATOR . get_include_path()); include "Ze
<?php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/London');
set_include_path('.' . PATH_SEPARATOR . './library'
. PATH_SEPARATOR . './application/models/'
. PATH_SEPARATOR . get_include_path());
include "Zend/Loader.php";
Zend_Loader::loadClass('Zend_Controller_Front');
// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
// run!
$frontController->dispatch();
?>
Zend/Controller/Front.php
<?php
...
class Zend_Controller_Front
{
...
protected static $_instance = null;
...
protected $_throwExceptions = false;
...
protected function __construct()
{
$this->_plugins = new Zend_Controller_Plugin_Broker();
}
...
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
...
public function throwExceptions($flag = null)
{
if ($flag !== null) {
$this->_throwExceptions = (bool) $flag;
return $this;
}
return $this->_throwExceptions;
}
...
}
...
?>
问题:
$this->\u plugins=new Zend\u Controller\u Plugin\u Broker()代码>
这个类的用途是什么:Zend\u Controller\u Plugin\u Broker
?似乎它在project/index.php中没有任何作用
公共函数throweexceptions($flag=null)
为什么$flag!==null,返回$this
当$flag==null时,通过异常返回$this->代码>?为什么这两个不都还美元呢
$frontController->setControllerDirectory('./应用程序/控制器')代码>“.”表示当前目录?为什么我们需要有“?”李>
这个类的用途是什么:Zend\u Controller\u Plugin\u Broker
它用于管理控制器插件。如果调用$front->registerPlugin()
插件代理将处理该调用。有关更多信息,请参阅
为什么是$flag!==null,返回$this;当$flag==null时,返回$this->\u throweexceptions
它允许该功能用于两个目的。如果不带参数调用它,将返回ThroweExceptions的当前值。如果使用参数调用它,则是在设置值
$frontController->setControllerDirectory(“./application/controllers”);“.”是指当前目录?为什么我们需要有“?”
为什么不呢?它使路径相对于当前目录更清晰
这个类的用途是什么:Zend\u Controller\u Plugin\u Broker
它用于管理控制器插件。如果调用$front->registerPlugin()
插件代理将处理该调用。有关更多信息,请参阅
为什么是$flag!==null,返回$this;当$flag==null时,返回$this->\u throweexceptions
它允许该功能用于两个目的。如果不带参数调用它,将返回ThroweExceptions的当前值。如果使用参数调用它,则是在设置值
$frontController->setControllerDirectory(“./application/controllers”);“.”是指当前目录?为什么我们需要有“?”
为什么不呢?它使路径相对于当前目录更清晰