PHP code to convert Fahrenheit to Celsius
Mark E.
<?php
$fahrenheit = 72; // Change this value to the Fahrenheit temperature you want to convert
$celsius = ($fahrenheit - 32) * (5/9);
echo $fahrenheit."°F is equivalent to ".$celsius."°C";
?>
In the above code, we first assign the Fahrenheit temperature to the variable $fahrenheit
. We then apply the formula (F - 32) * (5/9)
to convert Fahrenheit to Celsius and store the result in the variable $celsius
. Finally, we print the result using the echo
statement.
You can replace the value 72
in the code with any other Fahrenheit temperature you want to convert, and the code will calculate and display the equivalent Celsius temperature.