Kamis, 09 Agustus 2012

Contoh Program menggunakan PHP

Ini coding yang digunakan dalam program menghitung desimal menjadi hexa !
<?php
if (isset ($_POST['decimal'])) {
    $decimal = $_POST['decimal'];
    $original = $_POST['decimal'];
    if (preg_match('/[^0-9]/', $decimal)){
        die("Maaf, inputan salah ...");
    }
    else {
 
          $hex = dechex($decimal);
          
    
      $result = strrev($hex);
      echo "<h2>Bilangan $original (desimal) dalam bentuk hexadesimal adalah $result<h2>
      <h2><a href='des2hex.php'>Back</a> to the script</H2>";
        }
}
else {
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
       <form action="<?
        echo $_SERVER ['PHP_SELF'];
                    ?>"
             method="post">
           <h1>Masukkan Bilangan Desimal Disini (Cepat !!!) </h1>
           <input type="text" size="50" name="decimal"> <br>
           <input type="submit" value="konversi">
    
       </form>
    
    </body>
</html>
<?php
}
?>
Dan ini beberapa gambar dari hasil coding pemrograman diatas :



 
Ini gambar ke-Dua setelah memasukkan bilangan desimal :
 



Ini gambar ke-Tiga setelah memasukkan mengkonversikan bilangan desimal :



  

Tidak ada komentar:

Posting Komentar