Kalkulator PHP

Contoh Program Kalkulator dengan PHP

ini gan COPAS aja demi kecerdasan bangsa….. monggo gan… jgn lpa commengnya… demi kemajuan bersama…. hehe

<body>
<div id="pertambahan">
<p><h1>KALKULATOR</h1></p>
<form method="post" action="">
<input type="text" value="<?php echo $_POST["input1"]; ?>" name="input1" />
<select name="operator">
<option value="+">+</option>
<option value="-">-</option>
<option value="/">/</option>
<option value="*">x</option>
</select>
<input type="text" name="input2" value="<?php echo $_POST["input2"]; ?>" />
<input type="submit" name="kalkulasi" value="hasil" />
<input type="reset" value="reset" />
</form>
<?php
if(isset($_POST["kalkulasi"])){
$a = $_POST['input1'];
$b = $_POST['input2'];
$c = $_POST['operator'];
$d = $a.$c.$b;
$s = eval("return($d);");
//$jadi1 = eval("return($d);");
//echo $jadi1;
print $s;
}
?>

</div>
</body>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s