By now, you must have started writing those scripts and started working on PHP. Now, it’s time for you to learn about the operators available in PHP. An operator is something in which one or more values are fed and it gives another value as a result.
In general there are three types of operators:
There are many types of operators in PHP; some of them are useful but some are not. In this tutorial we will be studying about the most useful operators in PHP, which are:
$a=20;$b=10;$c=$a+$b;
$a=15;$b=10;$c=$a-$b;
$a=5;$b=2;$c=$a*$b;
$a=30;$b=2;$c=$a/$b;
$a=5;$b=2;$c=$a%$b;
$a=5;$a++;
$a=5;$a--;
Assignment OperatorsEqual to (=) $a=$b;Is same as $a=$b;Plus equal to (+=) $a+=$b;Is same as $a=$a+$b;Minus equal to (-=) $a-=$b;Is same as $a=$a-$b;Multiply equal to (*=) $a*=$b;Is same as $a=$a*$b;Divide equal to (/=) $a/=$b;Is same as $a=$a/$b;Modulus equal to (%=) $a%=$b;Is same as $a=$a%$b;Comparison OperatorsEqual to (==)3==5;Result: FalseNot equal to (!=) 3!=5;Result: True Greater than (>) 3>5;Result: False
Less than (<) 3<5;
Result: True
Greater than or equal to (>=) 3>=5;
Result: False
Less than or equal to (<=) 3<=5;Result: TrueLogical OperatorsAnd (&&) $a=5;$b=2;($a>4 && $b<3);Result: True
Or (||) $a=7;$b=8;($a<5 || $b<5);Result: False
Not (!) $a=5;$b=5;!($a==$b);Result: False
|