Codeigniter: Passing data from controller to view

The Solution to Codeigniter: Passing data from controller to view is


$data should be an array or an object: http://codeigniter.com/user_guide/general/views.html

$data = array(
    'title' => 'My Title',
    'heading' => 'My Heading',
    'message' => 'My Message'
);

$this->load->view('results_view', $data);

results_view.php

<html>
<?php 
//Access them like so
echo $title.$heading.$message; ?>
</html>

~ Answered on 2012-02-25 18:37:55


Most Viewed Questions: