1)create a class in application/library folder
2)create a php file to set data to library
3)in autoload.php call the library
Globals.php//in application/library
<?php
class Globals {
// Pass array as an argument to constructor function
public function __construct($config = array()) {
// Create associative array from the passed array
foreach ($config as $key => $value) {
$data[$key] = $value;
}
// Make instance of CodeIgniter to use its resources
$CI = & get_instance();
// Load data into CodeIgniter
$CI->load->vars($data);
}
}
?>
Globals.php// in application/config /
$config['name']='hithin';
demo.php//controller
<?php
defined('BASEPATH') OR EXIT('Dirrect access not allowed');
class Demo extends CI_Controller
{
public function __construct() {
parent::__construct();
}
public function index()
{
$this->load->view('demo_view');
}
}
demo_view.php //view
<?php
echo $name;
2)create a php file to set data to library
3)in autoload.php call the library
Globals.php//in application/library
<?php
class Globals {
// Pass array as an argument to constructor function
public function __construct($config = array()) {
// Create associative array from the passed array
foreach ($config as $key => $value) {
$data[$key] = $value;
}
// Make instance of CodeIgniter to use its resources
$CI = & get_instance();
// Load data into CodeIgniter
$CI->load->vars($data);
}
}
?>
Globals.php// in application/config /
$config['name']='hithin';
demo.php//controller
<?php
defined('BASEPATH') OR EXIT('Dirrect access not allowed');
class Demo extends CI_Controller
{
public function __construct() {
parent::__construct();
}
public function index()
{
$this->load->view('demo_view');
}
}
demo_view.php //view
<?php
echo $name;