Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 62 - 2617_JSSPS_C-7
P. 62

    <HTML>

                    <HEAD> <TITLE> Using Variables </TITLE> </HEAD>

                    <BODY>
                    <?php

                    $a = 10;
                                                                               Use of + operator
                    $b = 5;
                                                                                           Use of - operator
                    echo "The sum of two numbers is ", $a+$b;
                    echo "<br>The difference of two numbers is ", $a-$b;

                    echo "<br>The product of two numbers is ", $a*$b;
                                                                                          Use of * operator
                    ?>

                    </BODY>
                    </HTML>
                      Note that the <br> tag is used to print the text in next line. We get the following output by executing
                     the preceding script:

                      Relational operators: These operators help to compare quantities and return Boolean value ‘True’ or
                     ‘False’ as a result. Relational operators of PHP are ==, !=, >, <, >= and <=. Let us create a PHP script to
                     use some of the relational operators.

                     <HTML>

                    <HEAD> <TITLE> Using Variables </TITLE> </HEAD>
                    <BODY>
                    <?php

                    $a = 10;
                    $b = 5;
                    echo "a is greater than b: ", var_dump($a>$b);

                    echo "<br>a is less than b: ", var_dump($a==$b);
                    echo "<br>a is equal to b: ", var_dump($a>=$b);
                    ?>

                    </BODY>
                    </HTML>

                            Premium Edition-VII
                     60

| 57 58 59 60 61 62 63 64 65 66 67 |