CodeIgniter view loading not loading in order?

前端 未结 4 1115
生来不讨喜
生来不讨喜 2021-01-25 14:57

I have a Controller in CodeIgniter with the following code:

$this->load->view(\"first\");
echo \"LOL\";
$this->load->view(\"second\");
4条回答
  •  执念已碎
    2021-01-25 15:42

    To achieve what you are trying, you have to pass a third param to the function $this->load->view(...), indicating that you'll receive the view in a variable, and not to display it immediatly.

    Like this:

    echo $this->load->view("first", NULL, TRUE);
    echo "LOL";
    echo $this->load->view("second", NULL, TRUE);
    

    Look at the third param TRUE (the second is all the variables you want to pass to it). Don't forget to print the result of the view with echo. This is very useful if you want to store the views and process them, or print them in the order you wish.

提交回复
热议问题