有沒有人能翻譯一下這段,有點看不懂謝謝謝謝謝謝
<?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 '當前的Cookie為:<br>';
echo nl2br($content);
2019-08-04
<?php
setcookie('test', time());
//創建名為test的cookie,time()設置失效時間
ob_start();
//開始進入輸出緩沖區
print_r($_COOKIE);?
//$_COOKIE變量里面存放所有的cookie,這里的意思是輸出所有的cookie
$content = ob_get_contents();
//得到緩沖區里面的數據,存放在$content變量里面
$content = str_replace(" ", ' ', $content);
//將數據里面的空格替換為 的符號
ob_clean();
清除緩沖區
header("content-type:text/html; charset=utf-8");
//聲明文檔類型和編碼格式
echo '當前的Cookie為:<br>';
//輸出
echo nl2br($content);
//nl2br() 函數在字符串中的每個新行(\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.
以上內容,是在官方文檔上查閱~~
這段代碼,看上去像是打開緩沖區;讀取cookie,修改;清理緩沖區。