O'Reilly logo

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and Calling Your Own Functions

As you’ve already seen, PHP has a lot of built-in functions, addressing almost every need. More importantly, though, it has the capability for you to define and use your own functions for whatever purpose. The syntax for making your own function is

function function_name () {
   // Function code.
}

The name of your function can be any combination of letters, numbers, and the underscore, but it must begin with either a letter or the underscore. The main restriction is that you cannot use an existing function name for your function (print, echo, isset, and so on).

In PHP, as I mentioned in the first chapter, function names are case-insensitive (unlike variable names), so you could call that function using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required