Rabu, 22 Desember 2010

PHP VARIABLES

What is variables ?

Variables are used for storing values to the memory computer, like text strings, numbers or arrays. variable can be used over and over again in your PHP script. In PHP variable does not need to be declared before used it. If you stored integer value in your variable so your variable type is integer. PHP variable is case sensitif, variable $City is different with $CITY.

Naming Rules for Variables

  • All variables in PHP start with a $ sign symbol and must be followed with character or underscore ( _ ).
  • A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ).
  • A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_name), or with capitalization ($myName).

This is the correct variable name :

- $Name, $Sallary1, $_age, etc

This is the wrong variable name :

  • $1name ( wrong because after $ started with number).
  • $first name ( wrong because contain spaces).

TRY THIS !

1. This output our PHP program.

2. Type this coding.


3. Save at your localhost folder.
4. Open your browser and type your address file in url address ,example (localhost/var1.php). Press enter.

Tidak ada komentar:

Posting Komentar