Kamis, 09 Agustus 2012

Konversi Bilangan Desimal ke 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='Des_to_Hexa.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
}
?>

0 komentar:

Posting Komentar

Design by BlogSpotDesign | Ngetik Dot Com