This article describes how to add dynamic data to a view by using the CI framework. For more information about how to import data to a view by using an array or object, this array or object acts as the second parameter of the view loading function. If you use an object, the class variable is converted to an array element. Okay. Let's try it with your controller. Open the controller and add the following code
<? Php class Blog extends CI_Controller {
Function index ()
{
$ Data ['title'] = "My Real title ";
$ Data ['heading'] = "My Real heading ";
$ This-> load-> view ('blogview', $ data );
}
}
?>
Open your view file and Replace the text with the variable corresponding to the array. Note that $ key is directly used when the foreground page value is used instead of $ data.
<? Php echo $ title;?>
<? Php echo $ heading;?>
Summary: when the class variable $ data is passed, it is converted to an array element.
The method is very simple. You can join your project to make the best of your friends.