Page 171 - TrackpadV2.1_Class8
P. 171

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>











                                                                                                 Techipedia (PHP)  169
   166   167   168   169   170   171   172   173   174   175   176