亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

有沒有人能翻譯一下這段,有點看不懂謝謝謝謝謝謝

<?php

setcookie('test', time());

ob_start();

print_r($_COOKIE);?

$content = ob_get_contents();

$content = str_replace(" ", '&nbsp;', $content);

ob_clean();

header("content-type:text/html; charset=utf-8");

echo '當前的Cookie為:<br>';

echo nl2br($content);


正在回答

2 回答

<?php

setcookie('test', time());

//創建名為test的cookie,time()設置失效時間

ob_start();

//開始進入輸出緩沖區

print_r($_COOKIE);?

//$_COOKIE變量里面存放所有的cookie,這里的意思是輸出所有的cookie

$content = ob_get_contents();

//得到緩沖區里面的數據,存放在$content變量里面

$content = str_replace(" ", '&nbsp;', $content);

//將數據里面的空格替換為&nbsp的符號

ob_clean();

清除緩沖區

header("content-type:text/html; charset=utf-8");

//聲明文檔類型和編碼格式

echo '當前的Cookie為:<br>';

//輸出

echo nl2br($content);

//nl2br() 函數在字符串中的每個新行(\n)之前插入 HTML 換行符(<br> 或 <br />)。

6 回復 有任何疑惑可以回復我~

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,修改;清理緩沖區。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

有沒有人能翻譯一下這段,有點看不懂謝謝謝謝謝謝

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號