CHAPTER 10Working with Variables

Variables are an important part of any programming language, and that goes for PHP too. Variables are blocks of memory associated with a name and a data type, and variables contain data to be used in calculations, program flow, presentation, and so on.

PHP is a loosely typed language where variables can be used without declarations and where they can change type from line to line, in some cases without losing the content. This makes programming much easier than in more strictly typed languages, but it can also make it more difficult to debug the code.

All variable names in PHP start with a dollar ($) sign. This makes it easy for the scripting engine, as well as the reader, to identify variables anywhere in the ...

Get PHP 5 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.