在此程序中,我们将华氏温度转换为摄氏温度。

要将华氏度转换为摄氏度,我们使用公式 **'(F − 32) × 5/9 = C'。** 例如,如果用户输入的华氏度值为 **56**,则公式为 **(56°F − 32) × 5/9**,结果将是 **13.333°C**。
在此程序中,我们使用直接方法将华氏温度转换为摄氏温度。首先,我们从用户那里读取华氏度值并将其存储在变量中,然后将其应用于公式以找到摄氏温度。
步骤 1:接受用户输入的华氏度并将其存储到变量 **fahrenheit** 中。
步骤 2:将 **'((fahrenheit - 32) * 5) / 9'** 的计算值赋给变量 **celsius**。
步骤 3:将变量 **celsius** 的值打印为输入的 **华氏度** 的摄氏度值。
<?php
$fahrenheit = readline("Enter the fahrenheit: ");
$celsius = (($fahrenheit - 32) * 5) / 9;
$celsius = round($celsius, 3); // round() is used to limit the number of digit after the decimal
echo "Temperature in celsius is: $celsius";
?>
Enter the fahrenheit: 78 Temperature in celsius is: 25.556