PHP also having operators like other programming Languages like Java, C++, and C etc.
PHP operators are:-
- Assignment Operators.
- Arithmetic’s Operators.
- Comparison Operators.
- String Operators.
Assignment Operators:
PHP having assignment operators i.e. (=)
Example:
Arithmetic’s Operators:
PHP Arithmetic’s Operators are: +,-,*,/,%.
Example:
Comparison Operators:
Example:
String Operators:
PHP Strings Operators are:
There are generally tow String Operators in PHP
- First is a concatenation Operators (‘.’).
- The Second one is Assignment Operators (‘=’)
Example:
PHP Conditional Statements
PHP Conditional operators are:
- IF Statement.
- IF..ElSE Statement.
- IF..ELSEIF….Statement
- Switch Statement.
IF Statement: Like other programming language IF statement executes some statement when some particular condition is true.
Syntax: If (condition)
Code Execute;
Example:
IF..Else Statement: IF statement is true then execute one statement otherwise execute second statement.
Syntax:
Example:
IF..ELSEIF….Statement : If some condition is true then execute one statement else if some another statement then execute another statement. It is particularly an if else ladder.
Syntax:
Example:
Switch Statement: To overcome the multiple If-Else statement problems we used switch statement. It is conditional statement are used to perform different action based on different conditions.
Working of Switch Statement: It takes one variable as input and checks it against all the different cases you set for the switch statements.
Syntax: