This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo 'Contoh 1'; | |
?> | |
<?php echo 'Contoh 2 - tanpa semicolon dan langsung di tutup dengan tag php' ?> | |
<?php echo 'Contoh 3'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo 'Contoh 1'; // Ini digunakan untuk comment satu baris | |
/* Ini digunakan untuk commment lebih dari satu baris | |
dengan memblock beberapa baris */ | |
echo 'Contoh 2'; | |
echo 'Contoh 3'; # Ini juga digunakan untuk comment satu baris | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$benar=true; | |
$salah=false; | |
echo "benar = $benar, salah = $salah"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$saldo = 15000000; //value variabel saldo bernilai genap | |
$hutang = 200000; //value variabel hutang bernilai genap | |
echo "Saldo Rp." . $saldo; | |
echo "<br>"; | |
echo "Hutang Rp." . $hutang; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$un = 9.6; | |
$float2 = 14.0E10; | |
echo "Rata-Rata Nilai UN" . $un; | |
echo "<br>"; | |
echo "Contoh 2" . $float2; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//CONTOH PENGGUNAAN STRING | |
$contoh = "belajar"; | |
echo "$contoh"; | |
echo "Anak kelas 3 SMA sedang $contoh"; | |
echo "<br>"; | |
/*CONTOH SINGLE QUOTE | |
kata jum'at menggunakan tanda petik, kita tambahkan backslash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Nb : Value pada array dimulai dari 0 | |
$contoh = array("value0","value1","value2","..."); | |
//CONTOH | |
//variabel yang berisi array | |
$anggota = array("iqbal","ilham","farhan","cucu","syafi'i","febi","afri","labib"); | |
//menampilkan array | |
echo $anggota[1]; //output ilham |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// x pertama kali diberi nilai 9 | |
$x = 9; | |
if($x > 0) { | |
echo "Bisa dibandingkan karena tidak null"; | |
} | |
// x diberi NULL | |
$x = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nilai = 95; // $nilai disebut variabel, 95 disebut value | |
echo "$nilai"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Contoh penulisan variabel yang benar | |
$nama = "panji"; | |
$nilai1 = 80; | |
$_200ok = "TRUE"; | |
$ANGKA = "8"; | |
//Contoh penulisan variabel yang salah | |
$2you = "for me"; | |
$data dua = "Tidak Ada"; |