Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

STRUCTURAL CONTROL STATEMENT  If  If…..else….  If ….elseif…else.

Presentasi serupa


Presentasi berjudul: "STRUCTURAL CONTROL STATEMENT  If  If…..else….  If ….elseif…else."— Transcript presentasi:

1 STRUCTURAL CONTROL STATEMENT  If  If…..else….  If ….elseif…else

2  A PHP script is a set of statements  Statements can be assignments / assignment, function calls, loops, conditions even an empty statement.  In general, statements end with a semicolon (;)

3  Used to execute a block of statements if it meets certain conditions  The syntax is:  If the condition is true (true), the statement block will be done. if (condition) statement block

4 statement if <?php $Nilai = 95; $Keterangan = "Tidak Lulus"; if ($Nilai >=60) { $Keterangan = "Lulus";} printf("Nilai = %d ", $Nilai); printf("Keterangan = %s ",$Keterangan); ?>

5 Statement if <?php $Tabungan = ""; $Sukubunga = 0; $Tipe=1; if($Tipe=1){ $Tabungan = "Pribadi"; $Sukubunga=2.6; } if($Tipe=2){ $Tabungan = "Perusahaan Kecil"; $Sukubunga=3.3; } if($Tipe=3){ $Tabungan = "Perusahaan Besar"; $Sukubunga=3.6; } print ("Tipe Tabungan = $Tipe "); print ("Jenis Tabungan= $Tabungan "); print ("Suku Bunga = $Sukubunga "); ?>

6 statement IF Nilai Siswa : <?php if (isset ($Nilai)) { //Mengambil nilai integer $Nilai = intval ($Nilai); if ($Nilai >= 60) { $Keterangan = "Lulus"; } else { $Keterangan = "Tidak Lulus"; } print ("Nilai Ujian = $Nilai "); print ("Keterangan = $Keterangan"); } ?>

7  Principally similar to the statement of if  If... else... used for two branching.  If a condition is met, then do a block of statement 1, if not met, do block of statements 2.  syntax if (kondisi) { blok pernyataan 1; } Else { blok pernyataan 2; } if (kondisi): blok pernyataan1; Else: blok pernyataan2; Endif; atau

8 Statement IF Nilai Siswa: <?php if (isset($Nilai)) { if ($Nilai >=90) $Indeks = "A"; elseif ($Nilai >=80) $Indeks = "B"; elseif ($Nilai >=70) $Indeks = "C"; elseif ($Nilai >=60) $Indeks = "D"; else $Indeks = "E"; if ($Nilai >=60) $Keterangan = "Lulus"; else $Keterangan = "Tidak Lulus"; print ("Nilai Ujian = $Nilai "); print ("Keterangan = $Keterangan "); print ("Indeks =$Indeks"); } ?>

9 The first meeting is finished, you can download these materials at www.stmik-tasikmalaya.ac.id, download the menu, the course material ( filename = PHPMySQL3,Kamboja.) thank you see you at the next meeting


Download ppt "STRUCTURAL CONTROL STATEMENT  If  If…..else….  If ….elseif…else."

Presentasi serupa


Iklan oleh Google