CodeIgniter Forums
how to get the controller class function's returning value in views - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to get the controller class function's returning value in views (/showthread.php?tid=55463)



how to get the controller class function's returning value in views - El Forum - 10-27-2012

[eluser]Unknown[/eluser]
Hi, I am new in CI. And I am liking it. But I am still in confused about so many problems. right now I am facing this one problem is that When I write a function in CI Controller Class which returns a value. Now I want to output this returning value in a specific div of my views. When I do not return the data from the function, rather, just simply write echo in the function it shows the data on the top left corner of the screen. What I basically want is just get the function's returning value in a variable and print it in a specific div of mine. Which is pretty simple I know but its giving me huge problem.


how to get the controller class function's returning value in views - El Forum - 10-27-2012

[eluser]CroNiX[/eluser]
Code:
//Controller
$data['page_h1'] = 'This is my h1'; //access as $page_h1 in your view
$this->load->view('your_view_file', $data);

Code:
//View (/application/views/your_view_file.php)
<div><h1>&lt;?php echo $page_h1; ?&gt;</h1></div>



how to get the controller class function's returning value in views - El Forum - 10-28-2012

[eluser]Unknown[/eluser]
Hey Dude!!

Thank You very much, this really worked :-)