Arithmatic operators in PHP

, by Prashant Gunjal

In php operators are just like c ,c++ operators.  ie all + , - , * , / are present along with ++ (preincrement/Postincrement) , -- (Predecrement/Postdecrement).

Program :
<html>
<head>
    <title>PHP Arithmatic operators</title>
</head>
<body>
<?php
    $no1=20;
    $no2=10;
    $no3;
    $no3=$no1+$no2;
    echo "<br>Addition is = $no3";
    $no3=$no1-$no2;
    echo "<br>Substraction is = $no3";
    $no3=$no1*$no2;
    echo "<br>Multiplication is = $no3";
    $no3=$no1/$no2;
    echo "<br>Division is = $no3";
    $no3++;
    echo "<br>Postincrement of no3 is = $no3";
    echo "<br>Original no is = $no3 and preincrement is = ".++$no3;
    $no3--;
    echo "<br>Postdecrement of no3 is = $no3";
    echo "<br>Original no is = $no3 and predecrement is = ".--$no3;
?>
</body>
</html>

OUTPUT :


0 comments: