得到目前緩衝區的內容並刪除目前輸出緩。

ob_get_clean

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

ob_get_clean — 得到目前緩衝區的內容並刪除目前輸出緩。

說明

ob_get_clean(): string

得到目前緩衝區的內容並刪除目前輸出緩衝區。

ob_get_clean() 實質上是一起執行了 ob_get_contents() 和 ob_end_clean()。

返回值

返回輸出緩衝區的內容,並結束輸出緩衝區。如果輸出緩衝區不是活躍的,即返回 false 。

範例

示例 #1 A simple ob_get_clean() example

<?php

ob_start
();

echo 
"Hello World";

$out = ob_get_clean();
$out = strtolower($out);

var_dump($out);
?>

以上例程會輸出:


string(11) "hello world"

參見

Leave a Reply

Your email address will not be published. Required fields are marked *