1 / 7

Pemrograman Web (Manipulasi string)

Pemrograman Web (Manipulasi string). By . Rita Wiryasaputra. Manipulasi String. Strlen(string) → memperoleh panjang string Strtoupper(string) → mengubah huruf variabel string menjadi huruf besar Strtolower(string) → mengubah huruf variabel string menjadi huruf kecil

dimaia
Télécharger la présentation

Pemrograman Web (Manipulasi string)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pemrograman Web (Manipulasi string) By . Rita Wiryasaputra

  2. Manipulasi String • Strlen(string) → memperoleh panjang string • Strtoupper(string) → mengubah huruf variabel string menjadi huruf besar • Strtolower(string) → mengubah huruf variabel string menjadi huruf kecil • ucfirst(string) → huruf pertama variabel string menjadi huruf besar • Trim(string) → membuang karakter spasi kosong pada awal dan akhir string • Substr(string,awal,banyak) → mengambil bagian tertentu pada string

  3. Strlen (string1.php) <font size = 16> <form action=""> Masukkannama : <input type="text" name="kalimat" style="font-size:25pt" size="10"> <br> <input type="submit" value="hitung" style="font size:32pt"> <hr> </form> <? /* nama file : c:\...\phpgenap\string1.php dibuatoleh : Rita W. deskripsi : menghitungpanjang string */ $jmlh = strlen($kalimat); echo("jumlahhurufpadanama yang di-input : $jmlh"); ?>

  4. Strpos(string2.php) <font size = 16> <form action=""> Masukkannama : <input type="text" name="kalimat" style="font-size:25pt" size="10"><br> Huruf yang maudicari : <input type="text" name="huruf" style="font-size:25pt" size="10"> <br> <input type="submit" value="hitung" style="font size:32pt"> <hr> </form> <? /* nama file : c:\...\phpgenap\string22.php dibuatoleh : Rita W. deskripsi : posisikarakterdalam string dimulaidari 0 */ $jmlh = strpos($kalimat,$huruf); echo("Posisihurufpadanama yang di-input : $jmlh <br>");

  5. Lanjutan string2.php $kapital = strtoupper($kalimat); echo("Huruf kapitalnya : $kapital <br>"); $kecil = strtolower($kalimat); echo("Huruf kecilnya : $kecil <br>"); $awal= ucfirst($kalimat); echo("Huruf awal yang diberi kapital : $awal <br>"); $hitung=substr_count($kalimat,$huruf); echo ("Banyak huruf yang dicari : $hitung"); ?>

  6. Fungsi Fungsiadalahsekumpulanbaris program yang dapatdipakaiberulang kali tanpaharusmenuliskannyakembali.  Contoh: <? function cekUmur($umur){       If($umur<17){             echo “Andabelumbolehmenonton film ini!”;       }else{             echo “WahAndasudahtuarupanya”;       } } //penggunaanfungsi:  cekUmur(15); //hasilnya “Andabelumbolehmenonton film ini!” ?>

  7. Home Directory Pembuatan alias untuk home directory • Secara default C:\apache\htdocs • Dalamdirektori c:\apache\conf\httpd.conf dimodifikasidocumentroot “c:\apache\htdocs” menjadidocumentroot “d:\phpgenap” dan <directory “c:\apache\htdocs”> menjadi <directory “d:\phpgenap”>

More Related