O'Reilly logo

PHP Quick Scripting Reference by Mikael Olsson

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

CHAPTER 28

image

Advanced Variables

In addition to being a container for data, PHP variables have some other features that will be examined in this chapter. These are features that are not commonly used but are good to know about.

Curly syntax

A variable name can be explicitly specified by enclosing it in curly brackets. This is known as curly or complex syntax. To illustrate, the following code will output the variable even though it appears in the middle of a word.

$fruit = 'Apple';echo "Two {$fruit}s"; // "Two Apples"

More importantly, the curly syntax is useful for forming variable names out of expressions. Consider the following code which uses ...

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