Chapter 4 - Expressions and Control Flow in PHP Flashcards
What is an expression?
A combination of values, variables, operators and functions that results in a value.
What is a unary operator?
Takes a single operand.
Eg. $a++ or -$a
What is a binary operator?
Represents the bulk of php operators, including addition, subtraction, multiplication and division.
What is a binary operator?
Represents the bulk of php operators, including addition, subtraction, multiplication and division.
What is a literal?
The simplest form of an expression, which simply means something that evaluates itself, such as the number 15 or the string “Hello”.
What is a ternary operator?
Takes the form ? x: y. It’s a terse, single-line if statement that chooses between two expressions, depending on the result of a third one.
What is the associativity of
None
What is the associativity of (string) - cast to a string?
Right
What is the associativity of % Modulus?
Left
What does a relational operator do?
Tests two operands and returns a Boolean result of either True or False.
what are the three types of relational operators?
Equality
Comparison
Logical
What is a conditional?
Conditionals alter program flow. They enable you to ask questions about certain things and respond to the answers you get in different ways.
Give an example of PHP code for an if - else statement:
What does the SWITCH statement do?
It is useful in cases in which one variable or the result of an expression can have multiple values, which should each trigger a different function.
What does the ? Operator do?
It passes an expression that it must evalulate, along with two statements to execute. One for when the expression evaluates to TRUE and the other for when it is FALSE.