Pada pembahasan sebelumnya kita membahas tentang sejarah PHP, pengertian PHP,dll. dan saya pun baru belajar sedikit-sedikit tentang pemograman PHP. 
Nah sekarang kita coba membuat contoh program melalui PHP.
langsung saja kita lihat codingnya :)
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<?php
if (isset($_POST['decimal'])){
    $decimal = $_POST['decimal'];
    $original = $_POST['decimal'];
    $binary='';
    if (preg_match('/[^0-9]/',$decimal)){
        die("maaf.inputan salah.. ");
    }
    else{
        while ($decimal>0){
            if($decimal%2==0){
                $binary .=0;
                $decimal /=2;
            }
            else{
                $binary .=1;
                $decimal =($decimal/2)-0.5;
                //echo "<br>$decimal<br>";
            }
        }
        $result = strrev($binary);
        echo"bilangan $original(decimal)dalam biner adalah $result.
        <a href='konersi_Des_to_Biner.php'>Back</a> to the script";
    }
}
    
 else   {
?> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>"
              method="POST">
            <h3> Masukkan bilangan Desimal disini (cepat!!!):
            </h3> <input type="text" size="50" name="decimal">
            <input type= "submit" value="Konversikan!">
    </form> 
       
        <?php
        // put your code here
        ?>
    </body>
</html>
<?php
}
?>
kalo sudah ditulis codingnya sekarang coba tekan shift f6. kalo sudah pasti muncul ini melalui browser
maka keluarlah hasilnya :) semoga bermanfaat ;)

