PHP Program to convert kilometers to miles

How to convert kilometers to miles?

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

How to convert the kilometer to miles using PHP?

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 then to calculate the miles we must get the product of km and 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.

ALGORITHM

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 Source Code

                                          <?php
$km = readline("Enter the KM: ");
$m = 0.621371;
$miles = $km * $m;
echo "$km Km is equal to $miles miles";
                                      

OUTPUT

Enter the KM: 56
56 Km is equal to 34.796776 miles