10 Creating Functions

Throughout this book, you’ve used dozens of functions that provide much-needed functionality, such as date(), setcookie(), and number_format(). Whereas those functions have already been defined by PHP, here you’ll be creating your own. However, once created, functions you’ve written and built-in PHP functions are used in the same manner.

Creating functions can save you oodles of time over the course of your programming life. In fact, they constitute a strong step in the process of creating Web applications and building a solid library of PHP code to use in future projects.

In this chapter, you’ll see how to write your own functions that perform specific tasks. After that, you’ll learn how to pass information to the ...

Get PHP for the Web: Visual QuickStart Guide, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.