Codeigniter Pass Data To View


Codeigniter pass data to view : Codeigniter provides functionality to pass data from the controller on views in form of array or object.


Codeigniter pass data to view Example

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Blogdataexample extends CI_Controller {

public function index(){

$data = array(
 'title' => 'Blog Data Example',
 'heading' => 'Blog Data Example Heading......',
 'content' => 'Demo content starts here.......'

);
$this->load->view('Blogdataexample',$data);
}
}   
?>                    

Try it »

You can pass data as an object :

Example :

$data =  new MyClassName();
$this->load->view('Blogdataexample',$data);

User Ans/Comments

📖 Read More


Advertisements