learning all about web
Selasa, 02 Juni 2020
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.

Selasa, 21 Desember 2010
LOOPING AT PHP
PHP have a looping syntax to loop command.
1.FOR :
<?php
// show 1 until 9
for ($k=1; $k <10; $k ++) {
echo $k."<br>"; //<br> for break line
}
?>
2.WHILE :
<?php
// show 1 until 9
$k = 1;
While ($k < 10) {
echo $k."<br>"; //<br> for break line
$k ++;
}
?>
3.DO..WHILE
<?php
// show 1 until 9
$k = 1;
Do {
echo $k."<br>"; //<br> for break line
$k ++;
} while ($k < 10)
?>
your first php programming
Now you can configure webserver with XAMPP tools. Install xampp for your computer and you can create PHP programming immediately. In this article we try created first PHP script.
1. Install XAMPP. If you don't have a XAMPP download in this urlhttp://www.apachefriends.org.
2. After installed XAMPP, open notepad or IDE PHP like codelobster, PsPad etc.
3. Type this on your IDE :
echo "HELLO THIS IS MY FIRST PHP SCRIPT";
4. Save that script at C:\xampp\htdocs ( if you installed xampp at C drive) with name hello.php.
5. Open your favorite browser (firefox, chrome etc).
6. Type at address localhost\hello.php
7. If succesed you can see this picture.
OK, Good Luck To Try!


