📜  PHP ob_get_clean()函数

📅  最后修改于: 2022-05-13 01:56:29.237000             🧑  作者: Mango

PHP ob_get_clean()函数

ob_get_clean()函数是一个内置的PHP函数,用于清理或删除当前输出缓冲区。它还用于在清理缓冲区后再次获得输出缓冲。 ob_get_clean()函数是ob_get_contents()ob_end_clean()的组合。

句法:

string|false ob_get_clean();

参数:它不接受任何参数。

返回值:该函数返回输出缓冲区的内容并结束输出缓冲。如果输出缓冲未激活,则返回false

示例 1:下面是ob_get_clean()功能的简单示例。

PHP


PHP
 "Welcome",
            "B" => "GeeksforGeeks",
            "C" => "Geeks"
        );
  
        foreach ($variable as $key => $value) {
            echo $key . " => " . $value;
            echo "
";         }     } }    ob_start();    // Creating an object of class GFG $object = new GFG();    // Calling function $object -> GFG_Funcion();    $saved_ob_level = ob_get_level();    $start_ob_level="";    while (ob_get_level() > $start_ob_level) {     ob_end_flush(); }    // Now, it is the final output buffer $content = ob_get_clean();    ?>


输出:

string(24) "Welcome to GeeksforGeeks"

示例 2:

PHP

 "Welcome",
            "B" => "GeeksforGeeks",
            "C" => "Geeks"
        );
  
        foreach ($variable as $key => $value) {
            echo $key . " => " . $value;
            echo "
";         }     } }    ob_start();    // Creating an object of class GFG $object = new GFG();    // Calling function $object -> GFG_Funcion();    $saved_ob_level = ob_get_level();    $start_ob_level="";    while (ob_get_level() > $start_ob_level) {     ob_end_flush(); }    // Now, it is the final output buffer $content = ob_get_clean();    ?>

输出:

A => Welcome
B => GeeksforGeeks
C => Geeks

参考: https://www. PHP.net/manual/en/函数.ob-get-clean。 PHP