It is a simple mathematical program in PHP to convert user input value in kilometers into equivalent miles. We recommend you go through the following topics for a better understanding of the program
In this program, we are converting the kilometers into miles. To convert km to miles we have to multiply the value of km by 0.621371. For example, if the entered kilometer is 10 then the equivalent miles will be 6.21371
To convert the km to miles we first have to read the km into a variable km. After that, we must assign the value 0.621371 to a variable m then to calculate the miles we must get the product of km and m and store the result in the variable miles after that we can print the value of the variable miles as the miles equivalent to the entered km.
Step 1: Accept the value of kilometer into the variable km
Step 2: Assign the value 0.621371 into the variable m
Step 3: Assign the computed value of 'km * m' into the variable miles
Step 4: Print the value of the variable miles as the miles equivalent to the entered kilometer
<?php
$km = readline("Enter the KM: ");
$m = 0.621371;
$miles = $km * $m;
echo "$km Km is equal to $miles miles";
?>
Enter the KM: 56 56 Km is equal to 34.796776 miles