An operator is a symbol that represent a specific action.Operators are used to perform operations on variables and values.
Logical Operators
There are three types of logical operators
a) Logical AND operator
b) Logical OR operator
c) Logical NOT operator
a) Logical AND operator
In logical AND operator we check more than one conditional and all the condition must get true if we want to execute the statement. The best example of logical AND operator login system. In php double am-percent ( && ) sign is used as logical AND operator.
Example
Output of the above code
b) Logical OR operator
In logical OR operator if any condition get true then it will execute the statement. In Php double pipe ( || ) sign is used as logical OR operator.
Example
Unlike AND operator we don't need to get both the condition true. If any one of these get true it will execute the if block. Else block are only executed if both the condition are get false.
The output of the above code
c) Logical NOT operator
In Php exclamation mark ( ! ) is used as logical OR operator.
Example
The output of the above code
No comments:
Post a Comment