Why we use TRUE in load a view in CodeIgniter -
controller:
$data = array(); $page['left_content'] = $this->load->view('left_content', $data, true); $page['main_content'] = $this->load->view('left_content', $data, true); $page['right_content'] = $this->load->view('left_content', $data, true); $this->load->view('home',$data);
view:
<body> <?php if(isset($left_content)){echo $left_content;}?> <?php if(isset($main_content)){echo $main_content;}?> <?php if(isset($right_content)){echo $right_content;}?> </body>
please take above code. code used view page in main homepage. take test. if remove true code code not work properly. means when remove view not prints @ right place. prints @ top of main view or main home page. have googled lot can not find cause use it. want know why use true in code? thnx
when pass true optional parameter while loading view, returns content rather sending(displaying) data browser directly.
you can check in documentation:
there third optional parameter lets change behavior of function returns data string rather sending browser. can useful if want process data in way. if set parameter true (boolean) return data. default behavior false, sends browser. remember assign variable if want data returned:
$string = $this->load->view('myfile', '', true);
Comments
Post a Comment