18. PHP Program to convert Kilometers into Meters and Centimeters.
How does this program work?
- In this program we can find the distance between two cities in kilometers into meters and centimeters by using PHP.
- The distance between two cities is given by the user is stored in a variable.
- By using the given formula we can find the distance in meters and centimeters.
Here is the code
<html>
<head>
<title>PHP Program To convert Kilometers into meters and centimeters</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num" value="" placeholder="Enter distance between two cities in km"/>
</td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$d = $_POST['num'];
$m = $d*1000;
$cm = $d*100000;
echo " Total km in meters = ".$m;
echo " Total km in centimeters = ".$cm;
return 0;
}
?>
</body>
</html>