Metode & Algoritma | List Tutorials | Source Code | About | Sitemap
Konsultan Tesis
Bimbingan dan Konsultasi Tesis Informatika bersama team Project Graduate Indonesia. Konsultasi hanya untuk yang sudah me-Like FB kami (Silahkan LIKE tombol ini jika belum).
. Scroll kebawah untuk memasukan kode AntiSpam Protection. Hasil konsultasi akan kami kirimkan ke email Anda.

HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP




.


Metode dan Algoritma | HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP . Anda bisa melakukan konsultasi tentang HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP melalui form di samping kanan !!!

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:




Source Code ActionScript AS3 ASP.NET AJAX C / C++ C# Clipper COBOL ColdFusion DataFlex Delphi Emacs Lisp Fortran FoxPro Java J2ME JavaScript JScript Lingo MATLAB Perl PHP PostScript Python SQL VBScript Visual Basic 6.0 Visual Basic .NET Flash MySQL Oracle Android
Related Post :


Project-G
Judul: HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP
Rating: 100% based on 99998 ratings. 5 user reviews.
Ditulis Oleh hank2

Anda sedang membaca artikel tentang HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP, Semoga artikel tentang HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP ini sangat bermanfaat bagi teman-teman semua, jangan lupa untuk mengunjungi lagi melalui link HOW TO USE CONDITIONAL LOGIC IF STATEMENTS IN PHP.


Posted by: Metode Algoritma Updated at: 19.08

Label

Pengetahuan skripsi Belajar Panduan Film Operasi Sistem Tutorial tesis Biologi Pendidikan Software Buku Psikologi Hukum Hardware Troubleshooting kesehatan Film Horor Perbankan RPP dan Silabus SMA judul Pengembangan Kepribadian Pertemanan Administrasi Keluarga manajemen Hadits Kebidanan RPP dan Silabus SD Metode Pembelajaran tugas akhir Film Drama Virus Linux PTK SD RPP dan Silabus SMP Komputer dan IT Private SEO Tasawuf islam Ekonomi PTK SMP Pengertian Produk contoh program c++ listing c++ Kecerdasan Komputer Tidak Dapat Start Makalah Olahraga Pembelajaran Printer Akuntansi Bahasa Indonesia Cara cari uang dari Internet Judul Skripsi Online Penawaran buah pemrograman c++ Biografi Kemukjizatan Alquran Kurikulum Manajemen Pemasaran Matematika PTK SMA Sejarah Peradaban Islam Teknologi ta tes Administrasi Negara Anak Cara Pakai Jilbab Film Religion Flashdisk Ilmu Komunikasi Internet News Pemrograman Ulumul Quran Unik contoh kkp bsi ebook java programming lingkungan profesi keguruan program cpp Blog CPP Contoh-Tugas-Akhir Film Komedi Hardware-Komputer Manajemen Sumber Daya Manusia Organisasi Pemrograman-Komputer Ramadhan Tugas Akhir BSI Tugas Kuliah blogspot editor vi review sistem informasi Alexa Aliran Khawarij Aneh BlackBerry DBMS Database-Management-System Filsafat Fisika Gmail JQuery Jaringan Kaligrafi Kewarganegaraan Linux System Administrator Modul Praktikum PTK PAUD Saham Shell UNIX Winrar bio contoh tugas akhir fungsi cpu fungsi monitor java materi cpp bsi tips menjadi programer tugas akhir d3 Adsense for domain Archive Auto Blog joomla1.5 Backlink Gratis Bagian Komputer Bimbingan Konseling Budaya CEPAT KAYA Cara pengambilan data yang akurat Contoh-KKP Corel Draw Distro Linux Easy Gif Animator Free Backlink Hjsplit Keperawatan Kriptografi Kumpulan Jurnal Linux CentOS Meningkatkan Page Rank Modul Ms Excel PMB BSI 2012 PMB Nusa Mandiri PTC Berkualitas PTK SMK Pajak Perhotelan Pertanian RPP dan Silabus SMK Sejarah Linux Sejarah UNIX TA BSI Tafsir Teknik Informatika UANG ONLINE Umum alertpay cara parkir domain di google adsense ebook gratis fungsi mouse fungsi printer fungsi ram di android fungsi ram pada android fungsi speaker jasa tugas akhir judul tugas akhir login bsi metode penelitian pengenalan editor vi pengertian dan fungsi keyboard programer ta informatika tipe file database yii framework .data Alexa.com memang misterius Android BOM Bina Sarana Informatika Blog Gratisan Kualitas Mahal CARA GANTI FAVICON BLOGSPOT CARA KILAT SUBMIT DIREKTORY CARA MERUBAH TITLE BLOGSPOT CARI UANG DIINTERNET CPU Cara Instal file .deb di Linux Ubuntu Cara Instal file .sh di Linux Ubuntu Cara Klik iklan ptcclick.com Cara Melakukan Payout di kumpulblogger Cara Memasang Keyword di blogspot Cara Memperbaiki Broken Link Cara Nyepetin Internet Three (3) Cara Upload file 4shared Cara melihat Postingan Terpopuler di Blogspot Chatting dibayar dolar Contoh Soal BSI Contoh soal linux centos Contoh-Skripsi Daftar Isi Blog Database Delphi Dennis Ritchie Desain Web Download E-book Filesystem Linux Flexi unlimited Free Ebook GA Gambar Bangunan Gayus HYIP How to Streamline Body Iklan yang dibayar per Tampil Industri Info CPNS Info Merapi Terkini Info Pendidikan Internet Flexi murah Internet Three (3) Internetan Murah JASA TUGAS AKHIR INFORMATIKA Jaringan Komputer Jurnal Ilmiah Jurnal-Ilmiah Kampus Kartu Nama Ken Thompson Kimia Koruptor Indonesia Kursor Lius Torvalds Logika Algoritma MENGETAHUI HALAMAN YANG TERINDEX MENGETAHUI TEMPAT DOMAIN DIBELI Manajemen Personalia Materi Linux BSI Mematiakan Pop Up Telkomsel Membuat Flowchart Dengan Visio Mengganti Templete bogspot Modul Audio Video Modul Otomotif Mudahnya Mencari Uang di usia Muda Negara Bohongan Office PHP PLN PPC PTC PTC 1 kali klik langsung dibayar PTC AVG 3 PTC LEGIT Pemerintahan Pendaftaran CPNS Pendaftaran PNS (Pegawai Negeri Sipil) Photoshop Populer Programmer RDBMS Remaja yang Sukses Rumus Luas Bangun RUang STMIK Nusa Mandiri Sejarah Semua Tentang Life Style Server Smart Soft Business Card Smartphone Soal Syntaxhighlighter Tahun Baru Tangan kanan bos berasal dari remaja sekitar kantor Target Awal Sebuah Blog Telkomsel Tips Memilih Templete Blog/Web Tips-Blogspot Trik Bermain PPC Trik Mendatangkan Traffic Trik Menstabilkan Koneksi Internet Tutorial Pribadi SEO UNIX Video Website Windows XP2 Windows XP2 bermasalah array artikel tugas akhir baju bsi baju ormik bsi balance alertpay bash Linux beli alertpay biography Linus Torvalds bisnis online cara buat blog cara memilih nama domain yang keren cara mempercepat opera 10 cara mengetahui dimana asal domain di registrasi cara merawat printer canon cara merawat printer infus chronoforms client server contoh contoh baju bsi contoh proposal contoh proposal penelitian copy paste editor vi densus 88 dikit-dikit facebook domain domain adalah domain keren domain murah easyshare printer dock ebook facebook fungsi keyboard pada komputer fungsi papan kekunci fungsi printer dot matrix fungsi printer inkjet fungsi printer komputer fungsi printer laserjet fungsi processor fungsi ram pada hp fungsi ram pada komputer fungsi ram pada laptop fungsi scanner fungsi vga fungsi-teks google adsense kampang google adsense menipu hak akses file linux hak akses pada linux harga printer dot matrix hlookup hosting adalah hosting dan domain murah iframe informasi domain informatika jasa jasa bimbingan tugas akhir jasa pembuatan tugas akhir jasa programmer ta jasa ta informatika jasa tugas akhir sistem informasi jenis file jihad jual alertpay jual beli balance alertpay jual printer dot matrix judul ta informatika judul ta teknik informatika judul tugas akhir informatika jurnal informatika kajian pustaka kaos bsi kaos ormik bsi kecewa dengan google adsense kelebihan open source kernel linux kkp bsi kkp ka kkp manajemen informatika kodak easyshare printer dock 6000 kodak easyshare printer dock series 3 kodak easyshare printer dock series 3 cartridge kodak easyshare printer dock series 3 compatible cameras kode sms di php komponen CPU konsultan konsultan tugas akhir laser printer dot matrix printer logika dan algoritma lower macam-macam distro linux makalah ta informatika makalah tugas akhir informatika masterweb testimoni matriks cpp mematikan pop up telkomsel mencari uang di internet mengedit editor vi menghapus editor vi multi user paket internet 35000 per bulan pdf Free pembuatan ta informatika pengertian alertpay pengertian torrent perbedaan inkjet dan deskjet perbedaan printer inkjet dan printer laser perintah dasar Linux pop up populasi printer dot matrix epson price printer dot matrix murah program proposal tugas akhir sampel shell linux sistem skala suhu skripsi sistem informasi skripsi. ta sms gratis di blog sms gratis online sms kalo pulsa lagi habis software open source statement If statistika struktur direktori linux switch di java switch_expression teror tipe file tips tips komputer traffic trik tugas akhir informatika tugas akhir sistem informasi tugasakhir tvs printer dot matrix price list upper vlookup website bsi xbosyuda