• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please give me example of returning views as data

[eluser]Mario "St.Peter" Valentino[/eluser]

can anybody here give example about returning views as data.
i hope the full code( from controllers and view).
i'm newbie to codeigniter.
Please do me a favor



To return a view to a string you can use:
class Welcome extends CI_Controller
    function index()
        $data_to_send['title'] = 'Your webpage title';
        $string = $this->load->view('your_file.php', $data_to_send, true);

Is this what you need ?

[eluser]Mario "St.Peter" Valentino[/eluser]
i still confuse. here you save views to variable $string. how i display the result ?

echo $string;

but if you don't want to save the result to a string just use
$this->load->view('your_file.php', $data_to_send);

and it will show you the view automatically

[eluser]Mario "St.Peter" Valentino[/eluser]
ok now i understand. Thanks my friend for your explanation

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.