PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Controller Script

As a simple example, let us say your controller has a list of book data that it wants to have rendered by a view. The controller script might look something like this:

<?php
// use a model to get the data for book authors and titles.
$data = array(
    array(
        
'author' => 'Hernando de Soto',
        
'title' => 'The Mystery of Capitalism'
    
),
    array(
        
'author' => 'Henry Hazlitt',
        
'title' => 'Economics in One Lesson'
    
),
    array(
        
'author' => 'Milton Friedman',
        
'title' => 'Free to Choose'
    
)
);

// now assign the book data to a Zend_View instance
Zend_Loader::loadClass('Zend_View');
$view = new Zend_View();
$view->books $data;

// and render a view script called "booklist.php"
echo $view->render('booklist.php');

Zend Framework