- Behaviour similar to shell programs
- Functions / methods return constant codes
- Most commonly mapped to messages globally
- Wast range of variaties out there!
<?php
define( "ERR_FILE_NOT_WRITEABLE", 1 );
function writeToFile( $file, $content )
{
if ( ( $f = fopen( $file, "w" ) ) === false )
{
return ERR_FILE_NOT_WRITEABLE;
}
// ...
return 0;
}
if ( ( $err = writeToFile(
"/tmp/foo", "99 klingons..." ) ) !== 0 )
{
switch ( $err )
{
case ERR_FILE_NOT_WRITEABLE:
// Handle error...
break;
// ...
}
}
?>