PHP ob_get_clean() Function Last Updated : 18 Aug, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The ob_get_clean() function is an in-built PHP function that is used to clean or delete the current output buffer. It's also used to get the output buffering again after cleaning the buffer. The ob_get_clean() function is the combination of both ob_get_contents() and ob_end_clean(). Syntax: string|false ob_get_clean(); Parameters: It does not accept any parameter. Return value: This function returns the contents of the output buffer and end output buffering. If output buffering is not active, then it returns false. Example 1: Below is a simple example of ob_get_clean() functionality. PHP <?php // Create an output buffer ob_start(); echo "Welcome to GeeksforGeeks"; $out = ob_get_clean(); $out = strtolower($out); var_dump($out); ?> Output: string(24) "Welcome to GeeksforGeeks" Example 2: PHP <?php // Declare a class class GFG { public function GFG_Funcion() { $variable = array( "A" => "Welcome", "B" => "GeeksforGeeks", "C" => "Geeks" ); foreach ($variable as $key => $value) { echo $key . " => " . $value; echo "<br/>"; } } } 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(); ?> Output: A => Welcome B => GeeksforGeeks C => Geeks Reference: https://www.php.net/manual/en/function.ob-get-clean.php Comment More infoAdvertise with us Next Article PHP ob_get_contents() Function C coder36 Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP ob_get_contents() Function The ob_get_contents() is an inbuilt function in PHP that is used to capture what is currently being buffered by the output buffer. This function returns the output buffer. Syntaxob_get_contents(): string | falseParameter This function does not accept any parameters. Return Value The ob_get_contents( 2 min read PHP func_get_arg() Function The func_get_arg() function is an inbuilt function in PHP which is used to get a mentioned value from the argument passed as the parameters. Syntax: mixed func_get_arg( int $arg ) Parameters: This function accepts a single parameter as mentioned above and described below. $arg: This parameter holds 2 min read PHP | Imagick clear() Function The Imagick::clear() function is an inbuilt function in PHP which is used to clear all resource allocated to an Imagick object. Syntax: bool Imagick::clear( void ) Parameters: This function does not accept any parameter. It just clears off the resources of the Imagick object which is used to call th 2 min read PHP | Gmagick clear() Function The Gmagick::clear() function is an inbuilt function in PHP which is used to clear all resources associated to Gmagick object. Syntax: Gmagick Gmagick::clear( void ) Â Parameters: This function does not accepts any parameter. Return Value: This function returns the cleared Gmagick object. Errors/Exc 2 min read PHP ob_get_status() Function The ob_get_status() is an inbuilt function in PHP that is used for retrieving the status of the output buffer. Syntaxob_get_status(bool $full_status = false) : arrayParameter This function accepts only one parameter which is described below. $full_status: This is an optional parameter. If this param 2 min read PHP fclose() Function The fclose() function in PHP closes a file that was previously opened by fopen(). Closing a file releases the resource associated with it and makes sure all the data written to the file is properly saved. Not closing files can lead to resource leaks or incomplete data writing.Syntax:bool fclose(reso 2 min read Like