function square($num) { if (!is_numeric($num)) { pear::raiseError("Not a valid number"); } return $num * $num; }
$db = DB::connect("mysql://username:password@localhost/database"); if (DB::isError($db)) { pear::raiseError($db->getMessage()); }In this example, if the database connection fails, the raiseError method will be used to display an error message. The package library of this method is PEAR DB.