HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP


You saw in the last section that variables are storage areas for your text and numbers. But the reason you are storing this information is so that you can do something with them. If you have stored a username in a variable, for example, you'll then need to check if this is a valid username. To help you do the checking, something called Conditional Logic comes in very handy indeed. In this section, we'll take a look at just what Conditional Logic is. In the next section, we'll do some practical work.

Conditional Logic
Conditional Logic is all about asking "What happens IF ... ". When you press a button labelled "Don't Press this Button - Under any circumstance!" you are using Conditional Logic. You are asking, "Well, what happens IF I do press the button?"
You use Conditional Logic in your daily life all the time:
"If I turn the volume up on my stereo, will the neighbours be pleased?"
"If spend all my money on a new pair of shoes, will it make me happy?"
"If I study this course, will it improve my web site?"
Conditional Logic uses the "IF" word a lot. For the most part, you use Conditional Logic to test what is inside of a variable. You can then makes decisions based on what is inside of the variable. As an example, think about the username again. You might have a variable like this:
$User_Name = "My_Regular_Visitor";
The text "My_Regular_Visitor" will then be stored inside of the variable called $User_Name. You would use some Conditional Logic to test whether or not the variable $User_Name really does contain one of your regular visitors. You want to ask:
"IF $User_Name is authentic, then let $User_Name have access to the site."
In PHP, you use the "IF" word like this:
if ($User_Name = = "authentic") {
//Code to let user access the site here;
}
Without any checking, the if statement looks like this:
if ( ) {
}
You can see it more clearly, here. To test a variable or condition, you start with the word "if". You then have a pair of round brackets. You also need some more brackets - curly ones. These are just to the right of the letter "P" on your keyboard (Well, a UK keyboard, anyway). You need the left curly bracket first { and then the right curly bracket } at the end of your if statement. Get them the wrong way round, and PHP refuses to work. This will get you an error:
if ($User_Name = = "authentic") }
//Code to Let user access the site here;
{
And so will this:
if ($User_Name = = "authentic") {
//Code to Let user access the site here;
{
The first one has the curly brackets the wrong way round (should be left then right), while the second one has two left curly brackets.
In between the two round brackets, you type the condition you want to test. In the example above, we're testing to see whether the variable called $User_Name has a value of "authentic":
($User_Name = = "authentic")
Again, you'll get an error if you don't get your round brackets right! So the syntax for the if statement is this:
if (Condition_or_Variable_to_test) {
//your code here;
}
In the next lesson, we'll use if statements to display an image on the page.
We'll use the print statement to "print out" HTML code. As an example, take the following HTML code to display an image:
<IMG SRC =church.jpg>
Just plain HTML. But you can put that code inside of the print statement:
print ("<IMG SRC =images/church.jpg>");
When you run the code, the image should display. Of course, you'll need an image called church.jpg, and in a folder called images.
You can find these amongst the files you can download for this course, in the folder called images. (Go here to get the course files, if you haven't already.)
Copy the images folder to your www (root) directory. Then try the following script:
<?PHP
print ("<IMG SRC =images/church.jpg>");
?>
Save your script to the same folder as the images folder (though NOT inside the images folder). Now fire up your server, and give it a try. Hopefully, you'll see the church image display, as in the following graphic:

Cara Mudah Daftar Adsense

adsen1.gif (640×263)
sekedar berbagi trik, bagi anda yang ingin daftar adsen dengan mudah tanpa harus punya web dulu, tanpa harus beli domain dll. tapi ingat ini cara curang lhooo, saya tidak bertanggung jawab jika dikemudian hari ada sesuatu hal. silahkan daftar ke google.com/adsense terus pilih daftar atau signup, seperti biasanya silahkan isikan data  read more

cari honda CRV di Solo Surakarta Jawa Tengah

Saat nya bersantai di dalam ruang kabin yang kokoh , dan manjakan diri di dalam kabin yang lapang dan senyap , dengan berbagi fitur dan kemewahan setara sedan. cari honda CRV di solo surakarta ataupun jawa tengah , disini tempatnya. anda bisa hubungi kami. kami adalah sales resmi mobil honda di daerah solo dan sekitarnya. pembelian bisa melalui telepon , FB ataupun email. 

Saksikan sendiri betapa tak tertandinginya Honda CR-V dalam memberikan kebebasan di kelas SUV , bangku belakang dengan pembagian 60:40 yang dapat dilipat ke dua arah memberikan anda keluasan dalam mengatur ruang dalam dengan total kapasitas kabin 955 liter

Stabil Penuh Performa
Rasakan kestabilan saat berkendara yang tiada tara bersama Honda CR-V . Dengan merancang ulang penempatan mesin dan ban cadangan Honda berhasil merendahkan titik pusat berat kendaraan dan mengkobinasikanya dengan struktur body yang ringan dan seimbang serta suspensi baru yang kian sempurna  dengan kenyamanan sebuah sedan.

Hubungi Kami

Untuk Informasi dan Pembelian silahkan Hubungi :
Kyki Sutondo - 085647405646 atau 085229546063
Facebook : kiky bastinda
email : kiky_chevy@yahoo.com

terima kasih atas kunjungan anda.

Daftar Harga Mobil Honda Solo Surakarta Jawa Tengah

Up Date  1 Mei 2009

GAMBAR
TYPE
HARGA


New Jazz S  1.5 L  (manual)
199.500.000,-
New Jazz S  1.5 L  (Automatic)
209.500.000,-


New Jazz RS  1.5 L  (Manual)
215.000.000,-
New Jazz RS  1.5 L  (automatic)
225.000.000,-



All New City  S  1.5 L  (Manual)
261.500.000,-
All New  City  S  1.5 L  (Automatic)
276.500.000,-


All New City  Reclining  1.5 L  (Manual)
269.500.000,-
All New City  Reclining  1.5 L  (Automatic)
284.500.000,-



New  Civic  1.8 L  (Manual)
337.500.000,-
New  Civic  1.8 L  (Automatic)
350.500.000,-


New  Civic  2.0 L  (Automatic)
402.000.000,-





All New  CR-V  2.0 L  (Manual)
344.750.000,-
All New  CR-V  2.0 L  (Automatic)
355.750.000,-


All New  CR-V  2.4 L  (Automatic)
382.250.000,-





All New  Accord  VTi  2.4 L  (Manual)
427.250.000,-
All New  Accord  VTi  2.4 L  (Automatic)
442.250.000,-


All New  Accord  VTi-L  2.4 L  (Automatic)
481.250.000,-
All New  Accord  V-6  3.5 L  (Automatic)
709.250.000,-

Cari Honda Jazz Solo Surakarta


.. The Best Engineered Car is Here .. Temukan kebebasan lebih dalam mengekspresikan dirimu ! ..
Bersama inovasi dan kolaborasi sempurna dari segi desain , power , efesiensi dan utilitas ,
yang dirancang untuk gaya hidupmu yang aktif dan dinamis ....
Ayo berkendara dan raih harimu bersama ... All New Honda Jazz . ...

uji coba

blogger dalam uji coba