CHAPTER 4Functions

Computer programming exists in order to automate tasks of all sorts, from mortgage payment calculation to determining a person's daily recommended caloric intake. However, as these tasks grow increasingly complex, you'll often find they comprise other often repetitive tasks. For example, an e-commerce application might need to validate an e-mail address on several different pages, such as when a new user registers to use a Web site, when somebody wants to add a product review, or when a visitor signs up for a newsletter. The regular expression used to validate an e-mail address is quite complex, and therefore it would be ideal to maintain it in a single location rather than embed it into numerous pages, particularly if it ...

Get Beginning PHP and MySQL: From Novice to Professional, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.