PHP and MySQL Web Development - P34: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 132 Chapter 5 Reusing Code and Writing Functions Built-in functions are available to all PHP scripts but if you declare your own functions they are only available to the script s in which they were declared. It is a good idea to have one file containing your commonly used can then have a require statement in all your scripts to make your functions available. Within a function curly braces enclose the code that performs the task you require. Between these braces you can have anything that is legal elsewhere in a PHP script including function calls declarations of new variables or functions require or include statements and plain HTML. If we want to exit PHP within a function and type plain HTML we do it the same way as anywhere else in the script with a closing PHP tag followed by the following is a legal modification of the previous example and produces the same output php function my_function My function was called php Note that the PHP code is enclosed within matching opening and closing PHP tags. For most of the small code fragment examples in this book we do not show these tags. They are shown here because they are required within the example as well as above and below it. Naming Your Function The most important thing to consider when naming your functions is that the name should be short but descriptive. If your function creates a page header pageheader or page_header might be good names. A few restrictions are as follows Your function cannot have the same name as an existing function. Your function name can only contain letters digits and underscores. Your function name cannot begin with a digit. Many languages do allow you to reuse function feature is called function overloading. However PHP does not support function overloading so your function cannot have the same name as any built-in function or an existing user-defined function. Note that although every PHP script knows about all the built-in functions user-defined .