Variable in PHP

Posted by NanoTutor | Wednesday, February 25, 2009 | | 0 comments »

PHP recognize the existence of variables and operators, as other programming languages. Required to declare the variable and the value of a. The operator is required to perform mathematical calculations, giving values to variables in a particular, and to compare the value of two variables.

What are the variables?
Variables used to store data temporarily and the value can change each time the program is run. Data stored in the variable will be lost after the program finished executable.

PHP Variable and Value Types
PHP variables start with 'Variable name can be a combination of alphabet letters, numbers with a maximum length of 32 characters. Variable names are case-sensitive. Variable name can only be beginning with the letter or underscore, then the characters can be letters, numbers, and underscores. To be able to use variables, need to be two things:

Declaration

Declaration of variables is introduced to the program. In writing the PHP script, often combined with a declaration initialization. Example:

$ value, $ day.

Initialisation
Variable initialization is to provide a value for the first time to a variable. Example: Value = $ 50, $ = NamaHari Monday.

PHP variables have some type of value that is:

Integer (Numbers rounded)
The integer can be written in the form of:
Decimal number, for example: $ a = 1234;
Negative decimal number, for example: $ a = -123;
Hexadecimal number, for example: $ a = 0x1A with the same number of decimal 26;
Octal numbers, for example: $ a = 0123; with the same number of decimal 83
Floating Point
Floating Point Numbers can be declared using the following syntax:
$ a = 1234;
$ b = 1.2e3;
A maximum value of the Floating Point ~ 1.8e308 is reached with the accuracy 14 decimal digits.
String
Syntax string variables can be written in 3 ways, namely: Using single quotes ( ') example:
$ str = 'Hello Nano';
Using double quotes ( ") example:
$ str = "Hallo";
Using sign heredoc (<<<)

0 comments