亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

comet - How to clear php cache area
phpcn_u1582
phpcn_u1582 2017-05-16 13:10:26
0
1
590

The code is as follows

while(true){

        $getitem = mysql_query("select * from bulletin order by id desc limit 1");

        $item = mysql_fetch_array($getitem);

        echo json_encode($item,JSON_UNESCAPED_UNICODE);

        ob_flush();

        flush();

        ob_clean(); //Don’t quite understand the function of ob_clean

        mysql_data_seek($getitem,0);

        sleep(1);
}

The PHP cache area can output the contents of the cache area to the browser through ob_flush and flush, and the function of ob_clean is to clear the cache area, so the expected result is to output only the last piece of data each time. But in fact, the previous output is not cleared. How can I achieve my needs?

phpcn_u1582
phpcn_u1582

reply all(1)
洪濤

Usage of the following three functions

ob_get_contents() - 返回輸出緩沖區(qū)的內(nèi)容
ob_flush() - 沖刷出(送出)輸出緩沖區(qū)中的內(nèi)容
ob_clean() - 清空(擦掉)輸出緩沖區(qū)
ob_end_flush() - 沖刷出(送出)輸出緩沖區(qū)內(nèi)容并關(guān)閉緩沖
ob_end_clean() - 清空(擦除)緩沖區(qū)并關(guān)閉輸出緩沖
flush() - 刷新輸出緩沖    
通常是ob_flush();flush()同時(shí)一起使用
使用ob_start()把輸出那同輸出到緩沖區(qū),而不是到瀏覽器。
然后用ob_get_contents得到緩沖區(qū)的數(shù)據(jù)。

ob_start() opens a buffer on the server to save all output. So anytime echo is used, the output will be added to the buffer until the program ends or is terminated using ob_flush(). Then the content of the buffer in the server will be sent to the browser, which will be parsed and displayed by the browser.

The function ob_end_clean will clear the contents of the buffer and close the buffer, but will not output the content.
At this time, a function ob_get_contents() must be used in front of ob_end_clean() to obtain the contents of the buffer.
In this case, the content can be saved to a variable before executing ob_end_clean(), and then the variable can be operated after ob_end_clean().

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template