O'Reilly logo

Zend PHP 5 Certification Study Guide by Ben Ramsey, Davey Shafik

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

Functions

The heart of PHP programming is, arguably, the function. The ability to encapsulate any piece of code in such a way that it can be called again and again is invaluable—it is the cornerstone of structured procedural and object-oriented programming.

In this chapter, we focus on various aspects of creating and managing functions from within PHP scripts—therefore, this chapter is about writing functions, rather than using them.

Basic Syntax

Function syntax is—at its most basic—very simple. To create a new function, we simply use the keyword function, followed by an identifier, a pair of parentheses and braces (otherwise known as a code block):

function name() {
    // ... code
}

PHP function names are not case-sensitive. As with all identifiers ...

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