Valid variabels
a : Single-letter variables are good for temporary purposes, such as loop counters.
firstName : Variables that look like words help make your scripts easier to understand.
_1 : Traditionally, variables that begin with an underscore have special meaning to the local namespace.
inValid variabels
1 : The first character following the dollar sign may not be a number.
7Lucky : The first character following the dollar sign may not be a number. Use Lucky7 instead.
~password : ~ is not an alpha character and may not be used in variable names.
Last!Visit : ! is not an alpha character and may not be used in variable names. Use LastVisit or last_visit instead.
Compute-Mean : - is not an alpha character and may not be used in variable names. Use Compute_Mean instead.
The equal sign (=) is used to set the value of a variable. This is called the assignment operator. On the left side of the assignment operator is a variable that will receive a value. On the right side is an expression, which could be a simple string constant or a complex combination of operators, variables, and constants. The simplest form of assignment is from a constant expression. This could be a number or a string surrounded by quotes.
Sample of Variables Assignments
String Constants Integer Constants Double Constants
$myString = "leon"; $myInteger = 1; $myDouble = 123.456;
$myString = "\n"; $myInteger = -256; $myDouble = -98.76e5;
Most compiled languages, such as C or C++, require you to declare every variable along with the type of value that it will contain, and they require every code piece to state in advance what kind of values it is designed to work with. Most interpreted languages, such as PHP, allow variables to store any type of value and allow code units to work with any type of value. PHP doesn't even require you to explicitly declare a variable before you use it. Instead, the first time you assign a variable with some value, it is created. This simplifies development and helps you produce and maintain working programs more quickly. It also can lead to bugs when you use a variable before initializing it.
Variables in PHP don't have designated types. Instead, the type of the variable is considered to be the type of the value that it contains. The type of value that variables contain may be changed at any time. For example, assigning an integer to a variable that previously held a string converts the variable to an integer. This is in contrast to C, where each variable has a designated type. Assigning a value to a variable of a different type will make C attempt to convert the value so that it fits the variable.
How to use variabel
//create variable
$result = 2 + 5;
//create another variable
$doubleResult = $result * 2.001;
//print the second variable
print($doubleResult);
?>
As mentioned earlier, double-quoted strings and HERE docs may contain embedded variables. You may write a variable inside a string surrounded by double quotes, and its value appears in its place. This even works with arrays and objects. Listing below is an example of this technique. Notice that the name variable appears within a print statement between double quotes.
$name = "Zeev";
//Greet Zeev
print("Hello, $name!\n");
//Greet Zeev again
print <<< EOD
Hello again, $name!
How is it going?
EOD;
?>
Sunday, 12 October 2008
Layakkah kita?!
Pada saat wafatnya Sulaiman-khalifah sebelum Umar bin Abdul Aziiz-, ada seorang lelaki datang menemui Umar bin Abdul Aziiz. Lelaki itu berkata, "Relalah dengan ketentuan Allah,serahkanlah semua padaNya, dan harapkanlah apa yang ada di sisiNya. Sesungguhnya, di sisi Allah ada kebaikan abadi dan ada ganti dari musibah. Lihatlah kematian yang kau takutkan pada Sulaiman maka takutkanlah pada dirimu". Lelaki itu lalu beranjak pergi.
Umar berteriak,"Kembalikan dia padaku. Aku perlu bicara dengannya." Begitu lelaki itu datang kembali, Umar berkata "untuk apa kau katakan semua itu padaku?" Lelaki itu menjawab,"Jika kamu percaya pada ku, aku akan memberitahu kamu." Umar menukas, "Baik, aku percaya padamu."
Lelaki itu berkata, "Di Madinah, aku melihat kamu berpenampilan mewah dengan sombongnya, kau ulurkan sarungmu, kau uraikan rambutmu, kau tebarkan wewangian berlebihan sehingga aku takjub bagaimana Allah membiarkanmu untuk tetap untuk menjadi penghuni bumiNya. Ketika mengetahui keadaanmu itu, sudah semestinya aku memberikan belasungkawa dan memenuhi hakmu."
Umar lantas berpesan,"Saudaraku, jika kamu tinggal bersama kami di bumi kami, berjanjilah mengingatkan kami, dan jika kamu keluar, semoga dilindungi Allah."
Umar berteriak,"Kembalikan dia padaku. Aku perlu bicara dengannya." Begitu lelaki itu datang kembali, Umar berkata "untuk apa kau katakan semua itu padaku?" Lelaki itu menjawab,"Jika kamu percaya pada ku, aku akan memberitahu kamu." Umar menukas, "Baik, aku percaya padamu."
Lelaki itu berkata, "Di Madinah, aku melihat kamu berpenampilan mewah dengan sombongnya, kau ulurkan sarungmu, kau uraikan rambutmu, kau tebarkan wewangian berlebihan sehingga aku takjub bagaimana Allah membiarkanmu untuk tetap untuk menjadi penghuni bumiNya. Ketika mengetahui keadaanmu itu, sudah semestinya aku memberikan belasungkawa dan memenuhi hakmu."
Umar lantas berpesan,"Saudaraku, jika kamu tinggal bersama kami di bumi kami, berjanjilah mengingatkan kami, dan jika kamu keluar, semoga dilindungi Allah."
Friday, 29 August 2008
Einstein's Riddles ~ Neighbours
This quiz was made up by Albert Einstein and according to him 98% will not solve it.
There is a row of five houses, each having a different colour. In these houses live five people of various nationalities. Each of them nurtures a different beast, likes different drinks and smokes different brand of cigars.
There is a row of five houses, each having a different colour. In these houses live five people of various nationalities. Each of them nurtures a different beast, likes different drinks and smokes different brand of cigars.
- The Brit lives in the Red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The Green house is on the left of the White house.
- The owner of the Green house drinks coffee.
- The person who smokes Pall Mall rears birds.
- The owner of the Yellow house smokes Dunhill.
- The man living in the centre house drinks milk.
- The Norwegian lives in the first house.
- The man who smokes Blends lives next to the one who keeps cats.
- The man who keeps horses lives next to the man who smokes Dunhill.
- The man who smokes Blue Master drinks beer.
- The German smokes Prince.
- The Norwegian lives next to the Blue house.
- The man who smokes Blends has a neighbour who drinks water.
Who has fish at home? (are you one of the 2%).
Do you want to know the answer? Read this
Einstein's Riddles ~ Neighbours
This quiz was made up by Albert Einstein and according to him 98% will not solve it.
There is a row of five houses, each having a different colour. In these houses live five people of various nationalities. Each of them nurtures a different beast, likes different drinks and smokes different brand of cigars.
There is a row of five houses, each having a different colour. In these houses live five people of various nationalities. Each of them nurtures a different beast, likes different drinks and smokes different brand of cigars.
- The Brit lives in the Red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The Green house is on the left of the White house.
- The owner of the Green house drinks coffee.
- The person who smokes Pall Mall rears birds.
- The owner of the Yellow house smokes Dunhill.
- The man living in the centre house drinks milk.
- The Norwegian lives in the first house.
- The man who smokes Blends lives next to the one who keeps cats.
- The man who keeps horses lives next to the man who smokes Dunhill.
- The man who smokes Blue Master drinks beer.
- The German smokes Prince.
- The Norwegian lives next to the Blue house.
- The man who smokes Blends has a neighbour who drinks water.
Who has fish at home? (are you one of the 2%). -
Do you want to know the answer? Read this for the real source
Einstein's Riddles ~ Neighbours
This quiz was made up by Albert Einstein and according to him 98% will not solve it.
There is a row of five houses, each having a different colour. In these houses live five people of various nationalities. Each of them nurtures a different beast, likes different drinks and smokes different brand of cigars.
There is a row of five houses, each having a different colour. In these houses live five people of various nationalities. Each of them nurtures a different beast, likes different drinks and smokes different brand of cigars.
- The Brit lives in the Red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The Green house is on the left of the White house.
- The owner of the Green house drinks coffee.
- The person who smokes Pall Mall rears birds.
- The owner of the Yellow house smokes Dunhill.
- The man living in the centre house drinks milk.
- The Norwegian lives in the first house.
- The man who smokes Blends lives next to the one who keeps cats.
- The man who keeps horses lives next to the man who smokes Dunhill.
- The man who smokes Blue Master drinks beer.
- The German smokes Prince.
- The Norwegian lives next to the Blue house.
- The man who smokes Blends has a neighbour who drinks water.
Who has fish at home? (are you one of the 2%).
Do you want to know the answer? Read this for the real source
sebelum ramadhan tiba...

sebentar lagi ramadhan akan datang... bulan yang penuh ampunan dan hikmah. bulan dimana Allah mengobral pahalanya untuk mereka yang beriman dan melaksanakan shaum.
sebelum aku memasuki ramdhan ini, ijinkanlah daku memohon maap kepada sahabat semuanya atas berbagai khilaf dan salah ku... maafkan aku, sehingga aku bisa menjalankan shaum ku di tahun ini dengan penuh hikmat karena maaf dari kalian semua.
sebelum aku memasuki ramdhan ini, ijinkanlah daku memohon maap kepada sahabat semuanya atas berbagai khilaf dan salah ku... maafkan aku, sehingga aku bisa menjalankan shaum ku di tahun ini dengan penuh hikmat karena maaf dari kalian semua.
YA Allah, bukakan pintu maaf di hati sahabat-sahabatku... dan ridhoilah perbuatan ku... amin
Comments in PHP
In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.
<html><body> //This is a comment /*This isa commentblock*/ ?> </body> |
Subscribe to:
Posts (Atom)