Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 140 - 2606_PlugGPT_C7_Flipbook
P. 140

    Note that the comma is used to append the variable value with the text “Welcome”. Save the file
                      with Using Variables.php name. Now execute the script, as shown:

                      OPERATORS IN PHP

                      Operators are special symbols in PHP that are used to perform arithmetic or logical

                      computation. The variables of values used with the variables are known as operands. The
                      combination of operators and operands is called an expression. There are various types of
                      operators, which are as follows:

                          Arithmetic operators: These operators are used to do basic mathematical calculations. The

                         arithmetic operators of PHP are +, -, *, / and %. Let us create a PHP script to use some of the
                         arithmetic operators.

                        <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>

                      138   Premium Edition-VII

| 135 136 137 138 139 140 141 142 |