PHP Operators Tutorial
Notes:
PHP Operators
Expression:
A valid combination of operators and operands is known as an expression, on evaluation it yields a result.
Ex:
Valid Expressions:
2 + 2; // 4
2 * 2 + 2; // 6
Invalid Expressions:
+ 2 2; // error
* + 2 * + 2 ; //error
Operator: performs an operation on the given operand(s).
Types of operators: Operators in any programming language are broadly categorized into
Unary Operators: accept only one operand
Binary Operators: accept two operands.
Ternary Operators: accept three operands
Types of PHP Operators: LARA BICSS
L – Logical Operators : (&&, ||, !, and, or, xor)
A – Arithmetic Operators: (+, -, *, /, %,**)
R – Relational Operators: (<, >, <=, >=, ==, !=,<>, ===, !==)
A – Assignment Operators: (= , SHA/AA: (+=, -=, *=, /=,%=))
B – Bitwise Operators: (&, |, ~, ^, <<, >>)
I – Increment and Decrement Operators: (++ , --)
C – Conditional Operator: (?:)
S - String operators : . , .=
S – Special Operators: ->, =>, :: etc.
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a