May 2016
Intermediate to advanced
155 pages
2h 15m
English
© Mikael Olsson 2016
Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_28
Mikael Olsson1
(1)Hammarland, Finland
In addition to being a container for data, PHP variables have other features that are examined in this chapter. These are features that are not commonly used but are good to know about.
A variable name can be explicitly specified by enclosing it in curly brackets. This is known as curlyor complex syntax. To illustrate, the following code outputs 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 ...
Read now
Unlock full access