Variables
Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
PHP supports eight primitive types:
- Four scalar types:
- boolean
- integer
- float (floating-point number, aka double)
- string
- Two compound types:
- array
- object
- And finally three special types:
- resource
- NULL
- callable
// Integers: decimal, octal or hexadecimal $Var = 123; // Floating point $Var = 1.3e4; // Arrays or vectors $Var[2] = 123; // Text Strings $Var = "A Text String\n"; // Objects $Var = new oMyClass();
The scope of a variable is the context within which it is defined.
Constants
A constant is an identifier (name) for a simple value. That value cannot change during the execution of the script. A constant is case-sensitive by default. By convention, constant identifiers are always uppercase
There are two built-in constants, TRUE
and FALSE
(case-insensitive), which representthe two possible boolean values.
Expressions
Expressions are the most important building stones of PHP. The most basic forms of expressions are constants and variables.
A very common type of expressions are comparison expressions. These expressions evaluate to either FALSE
or TRUE
.
These expressions are most commonly used inside conditional execution, such as if
statements.
Operators
- Operator Precedence
- Arithmetic Operators
- Assignment Operators
- Bitwise Operators
- Comparison Operators
- Error Control Operators
- Execution Operators
- Incrementing/Decrementing Operators
- Logical Operators
- String Operators
- Array Operators
- Type Operators