In the general topics section on views it gives this example:
Let’s try it with your controller file. Open it add this code:
Now open your view file and change the text to variables that correspond to the array keys in your data:
I'm confused how the view file can access the variable $title without accessing the array that it is in. I would expect it to be something like
Are all of the array elements converted into stand alone variables?
Thank you.
Let’s try it with your controller file. Open it add this code:
Code:
<?php
class Blog extends CI_Controller {
public function index()
{
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
$this->load->view('blogview', $data);
}
}Now open your view file and change the text to variables that correspond to the array keys in your data:
Code:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h1><?php echo $heading;?></h1>
</body>
</html>I'm confused how the view file can access the variable $title without accessing the array that it is in. I would expect it to be something like
Code:
<html>
<head>
<title><?php echo $data['title']; ?></title>
</head>
<body>
<h1><?php echo $data['heading']; ?></h1>
</body>
</html>Are all of the array elements converted into stand alone variables?
Thank you.