Sunday, 9 June 2013

COMPOUND ASSIGNMENT AND INCREMENT & DECREMENT OPERATORS IN PHP

This post contains source code that explains the use of compound assignment operator and increment & decrement operator.
Source Code:-
/******************************************************************/
<html>
                <head>
                                <title>Operators</title>
                </head>
               
                <body>
                <?php
                                $var=4;
                                echo $var."<br />";

                                $var+=6; // $var=$var+6;
                                echo $var."<br />";

                                $var-=6; // $var=$var-6;
                                echo $var."<br />";

                                $var*=6; // $var=$var*6;
                                echo $var."<br />";

                                $var/=6; // $var=$var/6;
                                echo $var."<br />";

                               
                                $var=4;
                                echo $var."<br />";

                                $var++;
                                echo $var."<br />";

                                $var--;
                                echo $var."<br />";
                ?>
                </body>
</html>
/******************************************************************/
Output:-

4
10
4
24
4

4
5
4

No comments:

Post a Comment