<?php include 'header_superadmin.php'; ?> </head> <?php include 'menu_superadmin.php'; ?> <?php include 'script-data-mswrh-ppg.php'; ?> </div> <?php tambah(); ?> </div> </div> </div> <input type="hidden" id="dtp_input2" value=""/> <script type="text/javascript"> $('.form_date').datetimepicker({ language: 'id', weekStart: 1, todayBtn: 1, autoclose: 1, todayHighlight: 1, startView: 2,
echo "$string c3"; echo "<br>"; echo htmlspecialchars('<br>'); echo '$string c3 <br>'; echo strlen($string)."<br>"; echo str_word_count($string)."<br>"; echo strrev($string)."<br>"; echo strpos($string, "Bayu"); echo str_replace("Noval","noval",$string); */ function tambah($a, $b) { return $a + $b; } tambah(9, 2); //////////////////////////////////////////////// ?> </div> <h1>Fungsi Void</h1> <?php //buat 5 fungsi void function tulis($text = 'Noval Bayu') { echo "<br> Hello World! {$text} <br>"; } function tulisnama($nama = 'Bayu') { echo "<br>Organized by {$nama}@admin.com<br>"; } function namalengkap($nama = 'Bayu')
<?php include "../library/fungsi-class.php"; ?> <!DOCTYPE html> <html> <head> <title>Latihan Fungsi dan Object Oriented dalam PHP</title> </head> <body> <h1><?php echo tampilNama("Fahri"); ?> </h1> <p>Hasil penjumlahan dari 5 dan 9 adalah <?php echo 50 - tambah(5, 9); ?> </p> <h3><?php pangkat(7, 9); ?> </h3> <br> <?php $mhs = new Mahasiswa(); $mhs->printInfo(); echo "<br />"; $mhs->initialize("A12345", "Ingsun", 3.9); $mhs->printInfo(); ?>
return $hasil; } function kurang($a, $b) { echo "<br>"; $hasil = $a - $b; return $hasil; } function kali($a, $b) { echo "<br>"; $hasil = $a * $b; return $hasil; } function bagi($a, $b) { echo "<br>"; $hasil = $a / $b; return $hasil; } $hasil = tambah(4, 4); echo $hasil; $hasil = kurang(99, 9); echo $hasil; $hasil = kali(2, 10); echo $hasil; $hasil = bagi(9, 3); echo $hasil; ?> </body> </html>
{ if ($kondisi == 1) { if ($a < $b) { $a = $a + $b; } } if ($kondisi == 2) { if ($b < $s) { $b = $b + 10; } } $c = $a + $b; return $c; } $c = tambah($a, $b, 1); $c = tambah($a, $b, 2); /* require_once __DIR__ .'/config/config.php'; require_once __DIR__ .'/utility/database/mysql_db.php'; require_once __DIR__ . '/model/modelIjin.php'; $CONFIG= new config(); $CONFIG->open_connection(); $DB=new mysql_db(); $IJIN=new modelIjin(); $data = array( 'nomor' => "12312313", 'status_idstatus' => 1, 'tglijin' => "2013-12-31", 'atasnama' => "YOHANES",
function getContent($par) { global $s, $_submit, $menuAccess, $fFile, $dFile, $cUsername; switch ($par[mode]) { case "cek": $text = cek(); break; case "kta": $text = kota(); break; case "geo": $text = getField("select namaData from mst_data where kodeData='{$par['kodeKota']}'"); break; case "delNote": if (isset($menuAccess[$s]["delete"])) { $text = hapusNote(); } else { $text = lihat(); } break; case "editNote": if (isset($menuAccess[$s]["edit"])) { $text = empty($_submit) ? formNote() : ubahNote(); } else { $text = lihat(); } break; case "addNote": if (isset($menuAccess[$s]["add"])) { $text = empty($_submit) ? formNote() : tambahNote(); } else { $text = lihat(); } break; case "delBank": if (isset($menuAccess[$s]["delete"])) { $text = hapusBank(); } else { $text = lihat(); } break; case "editBank": if (isset($menuAccess[$s]["edit"])) { $text = empty($_submit) ? formBank() : ubahBank(); } else { $text = lihat(); } break; case "addBank": if (isset($menuAccess[$s]["add"])) { $text = empty($_submit) ? formBank() : tambahBank(); } else { $text = lihat(); } break; case "delContact": if (isset($menuAccess[$s]["delete"])) { $text = hapusContact(); } else { $text = lihat(); } break; case "editContact": if (isset($menuAccess[$s]["edit"])) { $text = empty($_submit) ? formContact() : ubahContact(); } else { $text = lihat(); } break; case "addContact": if (isset($menuAccess[$s]["add"])) { $text = empty($_submit) ? formContact() : tambahContact(); } else { $text = lihat(); } break; case "getProduk": $text = getProduk(); break; case "setProduk": $text = setProduk(); break; case "delFProduct": if (isset($menuAccess[$s]["delete"])) { $text = hapusFProduct(); } else { $text = lihat(); } break; case "delProduct": if (isset($menuAccess[$s]["delete"])) { $text = hapusProduct(); } else { $text = lihat(); } break; case "editProduct": if (isset($menuAccess[$s]["edit"])) { $text = empty($_submit) ? formProduct() : ubahProduct(); } else { $text = lihat(); } break; case "addProduct": if (isset($menuAccess[$s]["add"])) { $text = empty($_submit) ? formProduct() : tambahProduct(); } else { $text = lihat(); } break; case "getData": include 'dta_supplier_data.php'; break; case "delAddress": if (isset($menuAccess[$s]["delete"])) { $text = hapusAddress(); } else { $text = lihat(); } break; case "editAddress": if (isset($menuAccess[$s]["edit"])) { $text = empty($_submit) ? formAddress() : ubahAddress(); } else { $text = lihat(); } break; case "addAddress": if (isset($menuAccess[$s]["add"])) { $text = empty($_submit) ? formAddress() : tambahAddress(); } else { $text = lihat(); } break; case "update": if (isset($menuAccess[$s]["edit"])) { $text = ubah("update"); } break; case "delNpwp": if (isset($menuAccess[$s]["edit"])) { $text = hapusNpwp(); } else { $text = lihat(); } break; case "delId": if (isset($menuAccess[$s]["edit"])) { $text = hapusId(); } else { $text = lihat(); } break; case "delTdp": if (isset($menuAccess[$s]["edit"])) { $text = hapusTdp(); } else { $text = lihat(); } break; case "delSiup": if (isset($menuAccess[$s]["edit"])) { $text = hapusSiup(); } else { $text = lihat(); } break; case "delLogo": if (isset($menuAccess[$s]["edit"])) { $text = hapusLogo(); } else { $text = lihat(); } break; case "del": if (isset($menuAccess[$s]["delete"])) { $text = hapus(); } else { $text = lihat(); } break; case "edit": if (isset($menuAccess[$s]["add"])) { $text = empty($_submit) ? form() : ubah(); } else { $text = lihat(); } break; case "add": $text = isset($menuAccess[$s]["add"]) ? tambah() : lihat(); break; case "det": $text = detail(); break; default: $sql = "select * from dta_supplier where namaSupplier='' and createBy='{$cUsername}'"; $res = db($sql); while ($r = mysql_fetch_array($res)) { if (file_exists($fFile . $r[logoSupplier]) and $r[logoSupplier] != "") { unlink($fFile . $r[logoSupplier]); } $sql_ = "select * from dta_supplier_identity where kodeSupplier='{$r['kodeSupplier']}'"; $res_ = db($sql_); $r_ = mysql_fetch_array($res_); if (file_exists($dFile . $r_[siupIdentity_file]) and $r_[siupIdentity_file] != "") { unlink($dFile . $r_[siupIdentity_file]); } if (file_exists($dFile . $r_[tdpIdentity_file]) and $r_[tdpIdentity_file] != "") { unlink($dFile . $r_[tdpIdentity_file]); } if (file_exists($dFile . $r_[idIdentity_file]) and $r_[idIdentity_file] != "") { unlink($dFile . $r_[idIdentity_file]); } if (file_exists($dFile . $r_[npwpIdentity_file]) and $r_[npwpIdentity_file] != "") { unlink($dFile . $r_[npwpIdentity_file]); } db("delete from dta_supplier where kodeSupplier='{$r['kodeSupplier']}'"); db("delete from dta_supplier_address where kodeSupplier='{$r['kodeSupplier']}'"); db("delete from dta_supplier_produk where kodeSupplier='{$r['kodeSupplier']}'"); db("delete from dta_supplier_identity where kodeSupplier='{$r['kodeSupplier']}'"); db("delete from dta_supplier_contact where kodeSupplier='{$r['kodeSupplier']}'"); db("delete from dta_supplier_bank where kodeSupplier='{$r['kodeSupplier']}'"); } $text = lihat(); break; } return $text; }
} familyName("Hage", "1975"); familyName("Steal", "1978"); familyName("Kai", "1983"); echo "</fieldset>"; echo "<fieldset>"; echo "<legend>13.Fungsi dengan nilai default pada argumen</legend>"; function aturTinggi($min = 50) { echo "Tinggi = {$min} <br>"; } aturTinggi(356); aturTinggi(); //tetatur default dengan diatas aturTinggi(101); aturTinggi(80); echo "</fieldset>"; echo "<fieldset>"; echo "<legend>14.Fungsi yang mengembalikan nilai</legend>"; function tambah($y, $k) { $m = $y + $k; return $m; } echo "5 + 10 = " . tambah(5, 10) . "<br>"; echo "24 + 8 = " . tambah(24, 8) . "<br>"; echo "2 + 9 = " . tambah(2, 9) . "<br>"; ?> </body> </html>
return $hasil; } function kurang($a, $b) { echo "<br>"; $hasil = $a - $b; return $hasil; } function kali($a, $b) { echo "<br>"; $hasil = $a * $b; return $hasil; } function bagi($a, $b) { echo "<br>"; $hasil = $a / $b; return $hasil; } $hasil = tambah(2, 3); echo $hasil; $hasil = kurang(10, 2); echo $hasil; $hasil = kali(7, 6); echo $hasil; $hasil = bagi(20, 4); echo $hasil; ?> </body> </html>