有沒(méi)有人能翻譯一下這段,有點(diǎn)看不懂謝謝謝謝謝謝
<?php
setcookie('test', time());
ob_start();
print_r($_COOKIE);?
$content = ob_get_contents();
$content = str_replace(" ", ' ', $content);
ob_clean();
header("content-type:text/html; charset=utf-8");
echo '當(dāng)前的Cookie為:<br>';
echo nl2br($content);
2019-08-04
<?php
setcookie('test', time());
//創(chuàng)建名為test的cookie,time()設(shè)置失效時(shí)間
ob_start();
//開始進(jìn)入輸出緩沖區(qū)
print_r($_COOKIE);?
//$_COOKIE變量里面存放所有的cookie,這里的意思是輸出所有的cookie
$content = ob_get_contents();
//得到緩沖區(qū)里面的數(shù)據(jù),存放在$content變量里面
$content = str_replace(" ", ' ', $content);
//將數(shù)據(jù)里面的空格替換為 的符號(hào)
ob_clean();
清除緩沖區(qū)
header("content-type:text/html; charset=utf-8");
//聲明文檔類型和編碼格式
echo '當(dāng)前的Cookie為:<br>';
//輸出
echo nl2br($content);
//nl2br() 函數(shù)在字符串中的每個(gè)新行(\n)之前插入 HTML 換行符(<br> 或 <br />)。
2019-05-31
1.ob_start?—?Turn on output buffering
This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.
The contents of this internal buffer may be copied into a string variable using?ob_get_contents(). To output what is stored in the internal buffer, use?ob_end_flush(). Alternatively,?ob_end_clean()?will silently discard the buffer contents.
2.ob_clean?—?Clean (erase) the output buffer
This function discards the contents of the output buffer.
This function does not destroy the output buffer like?ob_end_clean()?does.
The output buffer must be started by?ob_start()?with?PHP_OUTPUT_HANDLER_CLEANABLE?flag. Otherwise?ob_clean()?will not work.
3.ob_get_contents?—?Return the contents of the output buffer
Gets the contents of the output buffer without clearing it.
以上內(nèi)容,是在官方文檔上查閱~~
這段代碼,看上去像是打開緩沖區(qū);讀取cookie,修改;清理緩沖區(qū)。