Variables in PHP3:40 with Alena Holligan
Variables are the most basic way of storing and keeping track of information in a program. Throughout this course, we'll be covering the 4 scalar, or base variable types that are supported in PHP: boolean, integer, float and string.
Variables in PHP
The type of a variable is not usually set by the programmer; rather, it is decided at runtime by PHP depending on the context in which that variable is used. PHP supports eight primitive types.
- Four scalar types:
- float (floating-point number, aka double)
- Two compound types:
- And finally two special types:
Why variables can't start with a number.
This is a standard for all programming languages. Primarily to standardize between languages whose variables do not start with a symbol. It is easier for a compiler to make an assumption that if a token begins with a number, it is most likely a numeric value rather than a variable name and any non-numeric characters that are a part of the token would assist in determining the numeric type or number system (12e5 is a valid number).
You need to sign up for Treehouse in order to download course files.Sign up