- Handle errors globally
- Single instance error handling
- Wast range of variaties out there!
<?php
class ErrorHandler
{
public static function raiseError(
$code, $message )
{
// Handle error
}
}
function writeToFile( $file, $content )
{
if ( ( $f = fopen( $file, "w" ) ) === false )
{
ErrorHandler::raiseError(
10,
"File not writeable <$file>"
);
}
}
writeToFile( "/tmp/foo", "99 ferenghi..." );
?>