项目/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 "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->_plugins = new Zend_Controller_Plugin_Broker();
这个类的用途是什么:Zend_Controller_Plugin_Broker
?似乎它在 project/index.php 中没有做任何事情public function throwExceptions($flag = null)
为什么 ?$flag !== null, return $this;
_$flag == null, return $this->_throwExceptions;
为什么不都返回 $this?$frontController->setControllerDirectory('./application/controllers');
“。” 是指当前目录?为什么我们需要有“。”?