LECTURE 3-Expressions & Operators
LECTURE 3-Expressions & Operators
Department of ICT
Online Material
Lecture 3: Expressions & Operators
Facilitator
B.Hemalatha
Assistant Professor
?: ternary
= += -= *= **= /= .= %= &= |= assignment operators
^= <<= >>= ??=
and logical
xor logical
or logical
Associativity
Associativity defines the order in which operators with the
same order of precedence are evaluated.
For example, look at: 2 / 2 * 2 The division and multiplication
operators have the same precedence, but the result of the
expression depends on which operation we do
first: 2/(2*2) // 0.5 (2/2)*2 // 2
Example: $n = 5;
echo $listing;
Miscellaneous Operators
Conditional (?:) It is the only ternary (three-operand)
operator and is therefore sometimes just called the ternary
operator.
The conditional operator evaluates the expression before
the ?.
If the expression is true, the operator returns the value of the
expression between the ? and :;
otherwise, the operator returns the value of the expression
after the :.
Assignment
Can I retrieve a single character of a string? How?
$24
$IAMHERE
$_error
$^b
${$var}
$yA_K
Do It Yourself
Click
THANK YOU