PHP has a rule of writing same with other programing language.That rules must be obeyed that a program is not any problems or error. Below is a writing at PHP.
1. To start PHP code must begin with symbol below:
- <?php your PHP code ?>
- <? your PHP code ?> in a special case.
- <script language="php"> your PHP code</script>
- <% your PHP code %>
2. PHP file must be .php, .php3, .php4 or .php5 extensions.
3. Every command or statement must be end with character ; (semicolon)
PHP Variable
Every other programing language PHP has a variable too. Variable at programing is a container or place to save or value container and the value could change. Method to writing a variable in PHP is not same with other programing language. In a declaration variable of PHP we must use symbol dollar ($) and then write name of variable. Writing variable of PHP has a rules, let's see above:
1. Writing must be start with letter or character underscore, can't with numbers.
2. Naming of variable there should be no spaces.
3. Have the quality case sensitive, Big or small letter is effect as differentiators.
4. Writing can use letter, number and underscore. they are can combined, but we must remember to starting a writing of variable we must obey rule number 1.
3. Every command or statement must be end with character ; (semicolon)
PHP Variable
Every other programing language PHP has a variable too. Variable at programing is a container or place to save or value container and the value could change. Method to writing a variable in PHP is not same with other programing language. In a declaration variable of PHP we must use symbol dollar ($) and then write name of variable. Writing variable of PHP has a rules, let's see above:
1. Writing must be start with letter or character underscore, can't with numbers.
2. Naming of variable there should be no spaces.
3. Have the quality case sensitive, Big or small letter is effect as differentiators.
4. Writing can use letter, number and underscore. they are can combined, but we must remember to starting a writing of variable we must obey rule number 1.
Let's see example of making a PHP variable. See the script below.
Click show to see and copy this code
At the above script we can see name of variable is $nama_variabel and variables above there has a value and there has not value, every data type of variables is different. Seen above name of variable only one , thet is $nama_variabel, but values of variable is different. Proven that value from a variable is could change. Let's see output of script above.
At the output above I only different output from variables with variabel pertama, variabel kedua, variabel ketiga and variabel keempat. But name of variable which is name shown is same. different of all is values because value at variable could change.
Maybe there is confused , why data type in declaration variable of PHP is not written. That is because data type at variable is follow value which is declaration, so value of variable is flexible. To know that value is String, integer, boolean data type we can use function of PHP that is gettype(). See the script below.
Maybe there is confused , why data type in declaration variable of PHP is not written. That is because data type at variable is follow value which is declaration, so value of variable is flexible. To know that value is String, integer, boolean data type we can use function of PHP that is gettype(). See the script below.
Let's see example of making a PHP variable. See the script below.
Until here my explanation to starting to learn PHP, Thanks for visiting and read my posting, i hope it can help you...
Click show to see and copy this code
The picture below is output of script above.
Constant
Constant is not different with regular variable, Different is value of constant is constant and writing of variable constant is different. The writing of constant is written with function define(), below is writing of constant.
define("variabel_name",value_of_variabel);
example:
define("PHI", 3.14);
From the constant above is can to translate into sentence ensuing, There is a constant named is "PHI" and value of this variable is 3,14, this value is will not change.
Until here my explanation to starting to learn PHP, Thanks for visiting and read my posting, i hope it can help you...
Learn and learn again...
No comments:
Post a Comment