Unit 2 Flashcards
Outline PHP’s variable conventions.
- They start with a dollar sign
- Variable type is not required when defining them
- They must start with a letter or underscore
- They cannot contain spaces
- Variable names are case-sensitive
Outline the conventions of a constant variable
- They are case sensitive
- Always uppercase
- Starts with a letter or underscore
- Automatically possess a global scope
- They are created using define() function and const keyword
What is the difference between const and define() in creating constant variables in PHP?
The keyword “const” defines constants at compile time, whereas the define() function defines constants at run time.
What are the scalar data types in PHP?
bool, int, string, float
What are the compound data types?
array, object, callable, iterable
What are the special data types in PHP?
resource, NULL
What are the three types of arrays in PHP?
- Indexed array
- Associative array
- Multi-dimensional array
What does the === operator do?
Returns true if both variables are equal and of the same type.
What does the <> operator do?
Returns true if both variables are not equal.
What does !== operator do?
Returns true if both operators are not equal or they are not of the same type
What does <=> operator do?
Spaceship returns an integer less than, equal to, or greater than zero, depending on if the variable on the left is less than, equal to, or greater than the variable on the right.
What does xor produce?
True if either variables is true, but not both
What is the concatenation operator?
.