I'm trying to understand the workflow of Zend application. For tests i've defined:
Controller - IndexController.php:
public function preDispatch() {
error_log('IndexController::preDispatch');
echo 'IndexController::preDispatch <br />'; }
public function init() {
error_log('IndexController::init');
echo 'IndexController::init <br />'; }
public function indexAction() {
error_log('IndexController::indexAction');
echo 'IndexController::indexAction <br />'; }
View script - index.phtml:
<?php
echo'index view script - echo';
$this->title = "ZF Tutorial";
$this->headTitle($this->title); ?>
<h3>index view script - content</h3>
Layout script - layout.phtml
...
<body>
<div id="content">
<?php
error_log('Layout1');
echo $this->layout()->content ?>
<h1>
<?php
error_log('Layout2');
echo $this->escape($this->title); ?>
</h1>
</div>
</body>
...
And here is my confusion. The order of error_log output is different from i've got in the browser.
error_log output (the expected order):
- IndexController::init
- IndexController::preDispatch
- IndexController::indexAction
- Layout1
- Layout2
the browser output:
- IndexController::init
- index view script - echo
- index view script - content
- IndexController::preDispatch
- IndexController::indexAction
- ZF Tutorial
Why do the output in controller is rendered AFTER view script? Is the echo results from preDispatch & indexAction buffered somehow to output view script content first?