Codeigniter视图和回声


Codeigniter View and echo

我有一个函数,它在codeigniter中处理网页的边栏。

如下所示:

function process_sidebar()
{
$this->load->view("first_access"); // ------------(1)
$this->load->view("second_access");// --------------(2)
echo "Here i want to show some data after loading view second_access"; //pls note here --(3)
$this->load->view("third_access"); // --------------------(4)
$this->load->view("fourth_access"); //-------------------------(5)
}

请检查订单号,但问题是代码点火器没有遵守订单。

它最后渲染视图,并首先显示CCD_ 1部分。。

我该如何克服这一点?

谢谢。

您需要append_output()而不是echo:

<?php
function process_sidebar()
{
    $this->load->view("first_access"); // ------------(1)
    $this->load->view("second_access");// --------------(2)
    $this->output->append_output("Here i want to show some data after loading view second_access"); //pls note here --(3)
    $this->load->view("third_access"); // --------------------(4)
    $this->load->view("fourth_access"); //-------------------------(5)
}

这就是视图在CodeIgniter中的工作方式,它不会立即显示,而是被缓冲,稍后一起显示。为了克服这个问题,如果要在中间显示的文本是静态的,请将其作为第二视图或第三视图的一部分。否则,将其作为第二视图或第三视图的变量,并将文本作为视图变量传递。