- Logic Operator
- Arithmetic Operator
- Assignment Operator
- Comparison Operator
1. Logic Operator
Logic operator is a operator which is use to comparison 2 or more value of variable which is data type boolean.
There are some of kinds logic operator, They are is:
- AND Logic
- OR Logic
- XOR Logic
- NOT Logic
- AND Logic
And logic will valuable if statement of two or more form value of variable is TRUE valuable. At PHP AND operator is marked with a character &&. Let's see a true table of AND logic below.
A
|
B
|
A^B
|
TRUE
|
TRUE
|
TRUE
|
TRUE
|
FALSE
|
FALSE
|
FALSE
|
TRUE
|
FALSE
|
FALSE
|
FALSE
|
FALSE
|
- OR Logic
OR Logic will valuable if one of statement from value of variable is TRUE valuable. At PHP OR operator is marked with a character ||. Let's see true table of OR logic below.
A
|
B
|
AvB
|
TRUE
|
TRUE
|
TRUE
|
TRUE
|
FALSE
|
TRUE
|
FALSE
|
TRUE
|
TRUE
|
FALSE
|
FALSE
|
FALSE
|
- XOR Logic
XOR Logic will TRUE valuable if statements there are have different value. At PHP XOR is marked with character XOR. Let's see true table of XOR logic below.
A
|
B
|
A xor B
|
TRUE
|
TRUE
|
FALSE
|
TRUE
|
FALSE
|
TRUE
|
FALSE
|
TRUE
|
TRUE
|
FALSE
|
FALSE
|
FALSE
|
-NOT Logic
Not logic is inverse of a statement. At PHP NOT logic is marked with character ! . Let's see true table of NOT logic below.
A | B |
TRUE | FALSE |
FALSE | TRUE |
2. Arithmetic Operator
Arithmetic operators is a operator which is use to do a mathematics calculation. Let's see list of arithmetic operator at table below.
Operator
|
Operation Name
|
Example
|
+ ( Unary ) | Positive | +5 |
- ( Unary ) | Negative | -5 |
+ | Addition | 5 + 5 |
- | Minus | 5 -5 |
* | Multiplication | 5 * 5 |
/ | Divider | 5 /5 |
% | Modulo | 5 % 5 |
3. Assignment Operator
Assignment operator is a operator which is use to give value for variable.
Example:
$name = "Riyan Trisna Wibowo";
At the example assignment operator "=" is use to insert string Riyan Trisna Wibowo into variable $name . There are many assignment operator except "=". Let's see list of another assignment operator.
Operator
|
Example
|
+= | $x+=9; same with $x = $x + 9; |
-= | $x-=9; same with $x = $x - 9; |
*= | $x*=9; same with $x = $x * 9; |
/= | $x/=9; same with $x = $x / 9; |
%= | $x%=9; same with $x = $x % 9; |
&= | $x=9; same with $x = $x & TRUE; |
^= | $x|=9; same with $x = $x ^ FALSE; |
|= | $x|=9; same with $x = $x | FALSE; |
.= | $x.='Riyan'; same with $x = $x .'Riyan'; |
-- | $x--; same with $x = $x-1; |
++ | $x++; same with $x = $x+1; |
4. Comparison Operator
Comparison Operator is a operator which is use to comparison value of two operand. Output comparison is declaration into boolean value, that is TRUE and FALSE. Let's see list of comparison operator below.
Operator
|
Example
|
== | Used to comparison left value and right value is same or not. |
!= | Used to comparison left value and right value is not same or not. |
> | Used to comparison left value is bigger that right value. |
< | Used to comparison left value is smaller that right value. |
>= | Used to comparison left value is bigger or equal to that right value. |
<= | Used to comparison left value is smaller or equal to that right value. |
Until here my explanation about operators of PHP, Thanks for visiting and read my posting, i hope it can help you...
Learn and learn again...
No comments:
Post a Comment