Bifalgorithm post · Computer science one · Using Variables
How do you assign values to variables in PHP?
How do you assign values to variables in PHP? (Computer science one · Using Variables) — "To use a variable in PHP, you simply need to assign a value to a name…
Ideas in this flowchart
- Using variables in PHP
- Assigning a value to a named variable places the variable in scope.
- Variable names must begin with a single dollar sign ($).
- The assignment operator is a single equal sign (=) and assigns from right to left.
- The variable appears on the left; the literal, variable, or expression appears on the right.
- Assignment examples
- $numUnits = 42;
- $costPerUnit = 32.79;
- $firstInitial = "C";
- Each assignment implicitly changes the variable's type.
- The examples become an integer, a floating-point number, and a string respectively.
- Assignment statements are terminated with a semicolon.
- Variable names may contain uppercase and lowercase letters, numbers, and underscores.
- Extended ASCII characters can be used, but their use is not recommended because diacritics may cause confusion.
- Variable names are case sensitive.
- The modern lower camel casing convention is used stylistically for variable names.