Blog

How to Call Views in CodeIgniter
Posted on June 25, 2015 in CodeIgniter, MVC, PHP by Matt Jennings

Inside a test Controller, Example of Calling a test View

<?php
class Test extends CI_Controller
{
    public function hello()
    {

        $this->load->view('test');
    }
}
?>

Inside a test View, Example of Calling Additional Views

<?php $this->load->view('partials/header'); ?>

<h1>Ninjas</h1>
<p>This view file is in /application/views/<b>test.php</b></p>
<p>I am going to have php calculate 456x331115.  The result is <?php echo 456*331115; ?></p>

<?php $this->load->view('partials/footer'); ?>

The Key Code in to Call Views

<?php 
$this->load->view('VIEW_NAME_HERE');
?>

Leave a Reply

To Top ↑