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