Prev | Current Page 295 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

*/
function subscribeUser() {
echo $this->email." added to the database!";
}
} #end Subscribe class
/* Assume that the e-mail address came from a subscription form. */
$_POST['email'] = "someuser@example.com";
CHAPTER 8 ?–  ERRO R AND EXCEPTION HANDL ING 229
/* Attempt to validate and add address to database. */
if (isset($_POST['email'])) {
$subscribe = new Subscribe();
if($subscribe->validateEmail($_POST['email']))
$subscribe->subscribeUser($_POST['email']);
}
?>
You can see that it??™s possible for two different exceptions to fire, one derived from
the base class and one extended from the Invalid_Email_Exception class.
Summary
The topics covered in this chapter touch upon many of the core error-handling practices
used in today??™s programming industry. While the implementation of such features
unfortunately remains more preference than policy, the introduction of capabilities
such as logging and error handling has contributed substantially to the ability of
programmers to detect and respond to otherwise unforeseen problems in their code.
The next chapter takes an in-depth look at PHP??™s string-parsing capabilities, covering
the language??™s powerful regular expression features, and offering insight into many
of the powerful string-manipulation functions.
231
?–  ?–  ?– 
C H A P T E R 9
Strings and
Regular Expressions
Programmers build applications that are based on established rules regarding the
classification, parsing, storage, and display of information, whether that information
consists of gourmet recipes, store sales receipts, poetry, or some other collection of
data.


Pages:
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307