The complete programming solution for the beginner
Operators in Php
An operator is a symbol that represent a specific action.Operators are used to perform operations on variables and values.
Types of operators in php 1.) Arithmetic Operator 2.) Comparison Operator 3.) Logical Operator 4.) Assignment operator 5.) Conditional Operator
1. Arithmetic Operator
In Arithmetic Operators we perform + Addition - Subtraction * Multiplication / Division % Modulus (to calculate reminder)
Example
2. Comparison Operator
Comparison Operator is used to compare between two and more variables and values . In Php double equal to (== ) sign is used used as compression operator.
Example
3.) Logical Operators
In Logical Operator we perform 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
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.
c) Logical NOT operator
In Php exclamation mark ( ! ) is used as logical OR operator.
Example
4. Assignment operator
Assignment Operator is used to assign value to any variable. We can assign the value directly to the variable or after performing any operation we can assign value to variable. To assign value to variable '=' sign is used.
Example
Don't get confused while using single equal to ( = ) sign or double equal to ( == ) sign. Single equal to sign is used for assignment but double equal to sign is used for compression
5.) Conditional Operator
Conditional operator contains < Less Than > Great Than <= Less Than Equal to >= Great Than Equal to
Example
No comments:
Post a Comment