Page 139 - 2606_PlugGPT_C7_Flipbook
P. 139

else                elseif              empty               enddeclare          endfor
                  endforeach          endif               endswitch           endwhile            extends

                  final               finally             fn                  for                 foreach
                  function            global              goto                if                  implements

                  include             instanceof          insteadof           interface           isset
                  list                namespace           new                 or                  print
                  private             protected           public              require             return

                  static              switch              throw               try                 use

                  var                 while               xor                 yield


                 VARIABLES IN PHP

                 A variable is a memory location that is used to store a value. When a variable is created, some
                 space is allocated in memory for it. This memory space is referred by the name that we give to an

                 identifier. A variable name must start with a $ (dollar) sign. For example,

                 <?php

                 $age = 12;
                 $name = "Divya";

                 $address = "12A, Stree No-4, Govindpuri";

                 $section = 'C';
                 ?>

                 Here 12, "Divya", "12A, Stree No-4, Govindpuri" and 'C' are the values assigned to variables
                 named age, name, address and section respectively. The = (equal) operator is used to assign
                 a value to a variable. Let us create a web page to show the use of variables. Type the following
                 code in notepad:


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

                 <BODY>

                 <?php
                 $name = "Divya";

                 echo "Welcome ", $name;

                 ?>
                 </BODY>

                 </HTML>




                                                                                                 Techipedia (PHP)  137
   134   135   136   137   138   139   140   141   142