Load view into a variable

后端 未结 3 2019
青春惊慌失措
青春惊慌失措 2020-12-24 12:15

Is there any way that I can get content of a PHP file in to variable?

I want to do this

$msg = $this->load->view(\'some_view\');
相关标签:
3条回答
  • 2020-12-24 12:47
    $string = $this->load->view('myfile', '', TRUE);
    

    https://codeigniter.com/user_guide/general/views.html#returning-views-as-data

    0 讨论(0)
  • 2020-12-24 12:58

    It is possible:

    $msg = $this->load->view('some_view', '', true);
    
    0 讨论(0)
  • 2020-12-24 13:04

    There is a third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to true (boolean) it will return data. The default behavior is false, which sends it to your browser. Remember to assign it to a variable if you want the data returned:

    $msg = $this->load->view('some_view', '', true);
    

    Source : http://codeigniter.com/user_guide/general/views.html

    0 讨论(0)
提交回复
热议问题