Page 175 - CITS - Computer Software Application -TT
P. 175

COMPUTER SOFTWARE APPLICATION - CITS




           Tip: If a variable is created without a value, it is automatically assigned a value of NULL.
           Variables can also be emptied by setting the value to NULL:

           Change Data Type






































           If you assign an integer value to a variable, the type will automatically be an integer.

           If you assign a string to the same variable, the type will change to a string
           PHP Variables
           In PHP, a variable is declared using a $ sign followed by the variable name. Here, some important points to know
           about variables:
           •  As PHP is a loosely typed language, so we do not need to declare the data types of the variables. It automatically
              analyzes the values and makes conversions to its correct datatype.
           •  After declaring a variable, it can be reused throughout the code.






           •  Assignment Operator (=) is used to assign the value to a variable.
           Syntax of declaring a variable in PHP is given below:

           Rules for declaring PHP variable:
           •  A variable must start with a dollar ($) sign, followed by the variable name.
           •  It can only contain alpha-numeric character and underscore (A-z, 0-9, _).
           •  A variable name must start with a letter or underscore (_) character.
           •  A PHP variable name cannot contain spaces.
           •  One thing to be kept in mind that the variable name cannot start with a number or special symbols.
           •  PHP variables are case-sensitive, so $name and $NAME both are treated as different variable.




                                                           162

                             CITS : IT&ITES - Computer  Software Application - Lesson 47 - 62
   170   171   172   173   174   175   176   177   178   179   180