Praktik PHP 1,2,3

 PHP Part 1

Source Code: 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,
    initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Part 1 PHP Trisna</title>
</head>
<body>
    <?php
        date_default_timezone_set("Asia/jakarta");
        echo '<div class="tgl">'. date("d-M-Y") .'</div>';
        echo '<br>';
        echo '<div class="text">Di Atas adalah tanggal hari
        ini</div>';
    ?>

    <p>Jam Digital: <b><span id="jam" style="font-size:24">
    </span></b></p>
    <p class="p-1">Trisna Almuti XII RPL</p>
    <h1 class="p-2">SMKN 1 JAKARTA</h1>

<script type="text/javascript">
         window.onload = function() { jam(); }
       
       function jam() {
           var e = document.getElementById('jam'),
           d = new Date(), h, m, s;
           h = d.getHours();
           m = set(d.getMinutes());
           s = set(d.getSeconds());
     
           e.innerHTML = h +':'+ m +':'+ s;
     
           setTimeout('jam()', 1000);
       }
     
       function set(e) {
           e = e < 10 ? '0'+ e : e;
           return e;
       }
</script>
</body>
</html>

Style/CSS :

* {
    margin: 0;
    padding: 0;
}

body {
    background-color: #212121;
}

.tgl {
    text-align: center;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 50px;
    color: orange;
    border: 5px solid;
    border-width: 50px;
}

.text {
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 40px;
    color: silver;
}

p {
    color: wheat;
    text-align: center;
    font-size: 50px;
    border: 5px solid;
    border-radius: 20%;
}

.p-1 {
    color: cyan;
    text-align: center;
    font-size: 50px;
    border: 5px solid;
    border-radius: 20%;
}

h1 {
    text-align: center;
    font-size: 100px;
    text-transform: uppercase;
    letter-spacing: 10px;
    background: linear-gradient(90deg, red, yellow, green,
    blue);
    -webkit-background-clip: text;
    background-size: 1000%;
    transform-origin: right;
    color: transparent;
    animation: h1 15s linear infinite;
    border: 8px solid;
}

@keyframes h1 {
    0% {
        background-position: 100% 0%;
    }
    50% {
        background-position: 0% 100%;
    }
    100% {
        background-position: 100% 0%;
    }
}


Hasil :

-----------------------------------------------------------------------------------------------------------------------------

PHP Part 2

Source Code :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,
    initial-scale=1.0">
    <title>Document</title>
   
</head>
<style type="text/css">
* {
    margin: 0;
    padding: 0;
}

body {
    align-items: center;
    text-align: center;
    font-size: 24px;
}

table {
    border: 2px solid;
    border-collapse: collapse;
    width: 30%;
    align-items: center;
    margin-left: auto;
    margin-right: auto;
}
th, td {
    align-items: center;
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}
tr:hover {background-color: orange;}
</style>
<body>
<?php
    $nama = "Trisna Almuti&quot";
    $umur = 18;
    $kelas = 12;
    $semester = 2;
    $jurusan = "RPL";
    $hobi = "Ngoding";
    $tanggallahir = "08/02/2004";
    $alamat = "JL.Kalianyar 04 Kec.Tambora DKI Jakarta";

    echo "Nama: $nama <br>";
    echo "Umur: $umur <br>";
    echo "Kelas: $kelas <br>";
    echo "Semester: $semester <br>";
    echo "Jurusan: $jurusan <br>";
    echo "Hobi: $hobi <br>";
    echo "Tanggal Lahir: $tanggallahir <br>";
    echo "Alamat: $alamat <br>";
?>

<table>
    <tr>
    <td>Nama Lengkap</td>
    <td>:</td>
    <td><?php echo $nama; ?></td>
    </tr>
    <tr>
    <td>Umur</td>
    <td>:</td>
    <td><?php echo $umur; ?></td>
    </tr>
    <tr>
    <td>Kelas</td>
    <td>:</td>
    <td><?php echo $kelas; ?></td>
    </tr>
    <tr>
    <td>Semester</td>
    <td>:</td>
    <td><?php echo $jurusan; ?></td>
    </tr>
    <tr>
    <td>Jurusan</td>
    <td>:</td>
    <td><?php echo $jurusan; ?></td>
    </tr>
    <tr>
    <td>Hobi</td>
    <td>:</td>
    <td><?php echo $hobi; ?></td>
    </tr>
    <tr>
    <td>Tanggal Lahir</td>
    <td>:</td>
    <td><?php echo $tanggallahir; ?></td>
    </tr>
    <tr>
    <td>Alamat</td>
    <td>:</td>
    <td><?php echo $alamat; ?></td>
    </tr>
</table>
</body>
</html>

Hasil :

-----------------------------------------------------------------------------------------------------------------------------
PHP Part 3
String :
Code: 
<?php
  $tes = "Usia Saya Sekarang 18 Tahun";
  echo $tes;
?>

<style type="text/css">
    * {
        font-size: 25px;
    }
</style>

Hasil : 

Integer
Code:
<?php
    $a = 2;
    $b = 3;
    echo "Saya Anak ke : ".$a."<br>";
    echo "Dari : ".$b." "."bersaudara";
?>

<style type="text/css">
    * {
        font-size: 25px;
    }
</style>

Hasil:

Float
Code:
<?php
    $angka = 12.999;
    echo "Harga Bakmie bang Rian seharga Rp.".$angka;
?>

<style type="text/css">
    * {
        font-size: 25px;
    }
</style>

Hasil:
Boolean
Code:
<?php
    $x = true;
    $y = false;
   
    echo "Hasil Pertama:".$x;
    echo "<br>";
    echo "Hasil Kedua:".$y."<br>";
    echo "Hasil Pertama ada Karna True";
    echo "<br>";
    echo "Hasil Kedua Tidak ada Karna False";
?>

<style type="text/css">
    * {
        font-size: 25px;
    }
</style>

Hasil:
Array
Code:
<?php
  // membuat array
  $tas = array('Pulpen','Buku Tulis','Penggaris');

  // menampilkan isi array
  echo $tas[0]."<br>";
  echo $tas[1]."<br>";
  echo $tas[2]."<br>";
?>

<style type="text/css">
    * {
        font-size: 25px;
    }
</style>

Hasil:
Object
Code:
<?php
class Car {
  public $color;
  public $model;
  public function __construct($color, $model) {
    $this->color = $color;
    $this->model = $model;
  }
  public function message() {
    return "Mobil ku adalah " . $this->color . " " .
    $this->model . "!";
  }
}

$myCar = new Car("black", "Volvo");
echo $myCar -> message();
echo "<br>";
$myCar = new Car("red", "Toyota");
echo $myCar -> message();
?>

<style type="text/css">
    * {
        font-size: 25px;
    }
</style>
Hasil:

NULL:
Code:
<div>
<?php
  // x pertama kali diberi nilai 2
  $x = 2;
  echo "Apakah 2 Lebih Besar dari 0";
  if($x >0){
    echo "<br>";
    echo "Benar 2 Lebih Besar dari 0";
    echo "<br>";
    echo "Bisa dibandingkan karena tidak null";
  }
  echo "<br>";
  echo "------------------------------------------------------------";
  echo "<br>";
  // x diberi NULL
  $x = null;
  echo "Apakah NULL Lebih Besar dari 0";
  echo "<br>";
  if($x > 0){
    echo "Tidak bisa dibandingkan karena null";
  }
  echo "<br>";
  echo "Tidak bisa dibandingkan karena null"
?>
</div>
<style type="text/css">
    * {
        font-size: 25px;
    }
    div {
      width: 20em;
      border: 2px solid;
    }
</style>
Hasil:
Intinya NULL tidak ada nilai sama sekali bahkan 0 sekalipun

Kunjungi Web:
PHP Part 1: https://php-part-1-smkn-1-jakarta.trisn0802.repl.co
PHP Part 2: https://php-part-2.trisn0802.repl.co
PHP Part 3 Spesial: 
https://glowing-text.trisn0802.repl.co

Posting Komentar

Lebih baru Lebih lama