Pertama-tama pastikan aplikasi Netbeans dan xampp sudah diinstal.
1. Buka aplikasi xampp aktifkan Apache dan MySQL dengan mengklik tombol start. Kemudian buka aplikasi netbeans.
2. Bila anda belum memiliki project. Ikuti step 1-3 pada postingan PHP sebelumnya (klik disini) untuk membuat project baru. Jika anda sudah memiliki project yang pernah anda buat sebelumnya, buka project tersebut di tab Project yang ada di sebelah kiri.
3. Klik kanan pada source files yang ada di sebelah kiri, pilih new > PHP File.. (lihat gambar).
4. Muncul jendela berikut. Beri nama file serta tentukan lokasi penyimpanannya. Klik Finish. 

5. Ketikkan script berikut di workspace.
<?php
echo "<font color= black face='Calibri'>";
echo "<table width='1000' border='0' cellpadding='4'>";
$nama = "Anes Paraswati Trisnanda";//deklarasi nama lengkap
echo "<tr>";
echo "<td width='227'>Nama Lengkap</td>";
echo "<td with='8'>:</td>";
echo "<td width='254'>$nama</td>";//pemangggilan variabel nama
echo "<td rowspan='9'> <img src='anes.jpg' width=150 height = 230> </td>";
echo "</tr>";
$panggilan = "Anes";//deklarasi nama panggilan
echo "<tr>";
echo "<td>Nama Panggilan</td>";
echo "<td>:</td>";
echo "<td>$panggilan</td>";//pemanggilan variabel panggilan
echo "</tr>";
$ttl = "Malang, 07 Agustus 1997";//deklarasi variabel ttl
echo "<tr>";
echo "<td>Tempat, Tanggal Lahir</td>";
echo "<td>:</td>";
echo "<td>$ttl</td>";//pemanggilan variabel ttl
echo "</tr>";
$smp = "SMPN 1 Malang";//deklarasi variabel smp
echo "<tr>";
echo "<td>Asal SMP</td>";
echo "<td>:</td>";
echo "<td>$smp</td>";//pemanggilan variabel smp
echo "</tr>";
$alamat = "JL. Raya Candi II 41 Malang";//deklarasi variabel alamat
echo "<tr>";
echo "<td>Alamat</td>";
echo "<td>:</td>";
echo "<td>$alamat</td>";//pemanggilan variabel alamat
echo "</tr>";
$tinggi = 160;//deklarasi variabel tinggi
$berat = "43";//deklarasi variabel berat
echo "<tr>";
echo "<td>Tinggi/berat</td>";
echo "<td>:</td>";
echo "<td>$tinggi / $berat</td>";//pemanggilan variabel tinggi dan berat
echo "</tr>";
$cita = "Web Developer";//deklarasi variabel cita
echo "<tr>";
echo "<td>Cita-cita</td>";
echo "<td>:</td>";
echo "<td>$cita</td>";//pemanggilan variabel cita
echo "</tr>";
$agama = "Islam";//deklarasi variabel agama
echo "<tr>";
echo "<td>Agama</td>";
echo "<td>:</td>";
echo "<td>$agama</td>";//pemanggilan variabel agama
echo "</tr>";
$hobi = "Menari";//deklarasi variabel hobi
echo "<tr>";
echo "<td>Hobi</td>";
echo "<td>:</td>";
echo "<td>$hobi</td>";//pemanggilan variabel hobi
echo "</tr>";
Atau anda juga dapat mengetikkan script berikut.
<!--komentar html -->
<?php
//definisi semua nilai masing-masing variable
$nama = "Anes Paraswati Trisnanda";
$panggilan = "Anes";
$ttl = "Malang, 7 Agustus 1997";
$smp = "SMPN 1 Malang";
$alamat = "Jl. Raya Candi II 41 Malang";
$tinggi = 160;
$berat = "43";
$cita = "Web Developer";
$agama = "Islam";
$hobi = "Menari";
?>
<font color= black face='Kristen ITC'>
<table width='1000' border='0' cellpadding="4">
<tr>
<td width='227'><?php echo "Nama Lengkap"; ?></td>
<td width='8'><?php echo ":"; ?></td>
<td width='254'><?php echo $nama; ?></td>
<td rowspan='9'> <img src='anes.jpg' width=150 height=230> </td>
</tr>
<tr>
<td><?php echo "Nama Panggilan"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo $panggilan; ?></td>
</tr>
<tr>
<td><?php echo "Tempat, Tanggal Lahir"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo $ttl; ?></td>
</tr>
<tr>
<td><?php echo "Asal SMP"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo $smp; ?></td>
</tr>
<tr>
<td><?php echo "Alamat"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo $alamat; ?></td>
</tr>
<tr>
<td><?php echo "Tinggi / berat"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo "$tinggi / $berat";?></td>
</tr>
<tr>
<td><?php echo "Cita-cita"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo "$cita";?></td>
</tr>
<tr>
<td><?php echo "Agama"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo "$agama";?></td>
</tr>
<tr>
<td><?php echo "Hobi"; ?></td>
<td><?php echo ":"; ?></td>
<td><?php echo "$hobi";?></td>
</tr>
</table>
6. Klik tombol Run. Maka tampilan pada browser akan seperti berikut. 


Double klik pada file yang hendak dilihat hasilnya. Dalam hal ini saya akan melihat hasil dari PraktikPHPscript2.php. Saya menggunakan script yang kedua. Maka tampilannya sebagai berikut.

CATATAN :
Dalam menginput foto, pastikan file foto tersebut berada satu folder dengan project anda.


Tidak ada komentar:
Posting Komentar