Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

ob_clean() - Trouble Understanding Code

$
0
0

Hello. I'm having a difficulty understanding the code below:

<?php
set_error_handler('errorHandler', E_ALL);

function errorHandler($number, $message, $file, $line){
	if(ob_get_length()) ob_clean();
	$errorMessage = 'Error: '.$number.'</br>'.
					'Message: '.$message.'</br>'.
					'File: '.$message.'</br>'.
					'Line: '.$message;
					
	echo $errorMessage;
}
?>

Specifically, the line 

if(ob_get_length()) ob_clean();

I've looked up what the function ob_clean() does, and I understand that it empties the output buffer, but I still don't see how it works within the code. I mean, what purpose would it serve to clean the buffer at the beginning of the function?


Viewing all articles
Browse latest Browse all 13200

Trending Articles