Skip to content

Instantly share code, notes, and snippets.

@inuvalogic
Last active January 28, 2017 14:42
Show Gist options
  • Save inuvalogic/1c76d448d1c9e1598cb40f03074a616c to your computer and use it in GitHub Desktop.
Save inuvalogic/1c76d448d1c9e1598cb40f03074a616c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Web PHP Pertama Saya</title>
</head>
<body>
<?php
echo "Web PHP Pertama Saya";
print "Hore saya bisa";
?>
<?= "Halo Halo Bandung"; ?>
</body>
</html>
<?php
$string = "ini sebuah var string";
$string_alternatif = 'ini sebuah var string';
$integer = 1800;
$float = 1.5;
$boolean = true;
$array = array(1,2,3,4);
$array_alternatif = [1,2,3,4];
$null = NULL;
$null_alternatif = null;
$empty_string = '';
<?php
// Penambahan
$z = $x + $y;
// Pengurangan
$z = $x - $y;
// Perkalian
$z = $x * $y;
// Pembagian
$z = $x / $y;
// Modulus
$z = $x % $y;
// Eksponen
$z = $x ** $y;
$x = 10;
$y = 5;
$z = ((($x%2 + $y)/$y)*$x**2);
echo $z;
<?php
$a = 10;
if ($a==10){
echo "A sama dengan sepuluh";
}
$a = 11;
if ($a==10){
echo "A sama dengan sepuluh";
} else {
echo "A bukan sepuluh tapi ".$a;
}
$kitty = "kucing";
if ($kitty!="kucing") {
echo "Kitty itu bukan kucing tapi boneka";
} else {
echo "Kitty itu seekor kucing";
}
<?php
$a = 10;
switch ($a) {
case 10:
echo "aku muncul karena A itu sepuluh";
break;
case "kucing":
echo "aku muncul karena A itu seekor kucing";
break;
default:
echo "apapun nilai A aku yang muncul";
break;
}
<form method="post">
<div>
<label for="judul">Judul</label>
<input type="text" name="judul">
</div>
<div>
<label for="isi">Isi</label>
<textarea name="isi"></textarea>
</div>
<button type="submit" name="submit">Tambah</button>
</form>
<?php
if (isset($_POST['submit']))
{
$judul = $_POST['judul'];
$isi = $_POST['isi'];
echo "Judul = ".$judul."<br>Isi = ".$isi;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment