Wednesday, January 3, 2018

What is Variable & types in PHP

Variables

Variables hold the data that  program manipulates while it runs, such as user information that  loaded from a database or entries that have been typed into an HTML form. In PHP, variables are denoted by a $ followed by the variable’s name. To assign a value to a variable, use an equals sign ( = ). This is known as the assignment operator .
In our basic PHP page example use the PHP equal statement to send a text welcome to text "welcome to PHP!" to the web browsers if we also said that PHP allows programmer to make their web page dynamic.
               if you could send the browser only literal text is wouldn't be very dynamic, since all of information would be hard - coded into the page. Instead you can use variables to represent your information can set PHP variables manually,  use them to store information have retrieved  from her database, are used them to keep val ues that user enter into a we  form.
           variable in PHP are done the noted by prefixing dollar sign($) symbol to the name that you use the syntax ($) sign number on planets in PHP code, variable naming in case sensitive so a PHP variable called dollar($) number of planets in different from a PHP variables call ($) number of planets.
                 Variable names are case-sensitive. This means that variables named $dinner , $Dinner , and $DINNER are separate and distinct, with no more in common than if they were named $breakfast , $lunch , and $supper . In practice, should avoid using variable names that differ only by letter case. They make programs difficult to read and debug.

Example :- 
$plates = 5 ; 
$dinner = 'Beef Chow-Fun' ; 
$cost_of_dinner = 8.95 ; 
$cost_of_lunch = 
$cost_of_dinner ;




Variable are to rule follow in PHP:-

1. Variable name must start with a letter or an underscore character (_).

2. Variable name can contain only letters, number, underscore or ASCII (American Standard Code for Information 
 Interchange) character that has a code from 127 to 255.

3. Uppercase or lowercase Basic Latin letters ( A-Z and a-z ) 

4. Digits ( 0-9 ) 

5. Any non-Basic Latin character (such as รง), if you’re using a character encoding such as UTF-8 for your program file.


PHP programming language define a different types of variable there are 8 types of variable are mansion:-

1 The integer types variable used in numeric data .
2.  The float type of variable used for numeric data
3.  The boolean types store simple yes/no or on/off information.
4.  The string type store textual information.
5. The array types can store a mixture of different types.
6.  The object type can store a mixture of different types.
7.  The null types are variable.
8.  The resource types variable.




            

0 comments:

Please comment and follow this site blog inbox