PHP Code to Convert Celsius to Fahrenheit
ADVERTISEMENTS
PHP code to convert celsius to Fahrenheit.
In this article, You will learn how to write PHP code to convert celsius to Fahrenheit.
Formula
F = (C * 9/5) + 32
Where
F = Fahrenheit
C = celsius
Source Code
<?php
// PHP Code to Convert Celsius to Fahrenheit
$c = 7; // value of the celsius
$f = NULL; // value of the fahrenheit
// It will convert celsius to Fahrenheit
$f = (float)(($c * 9 / 5) + 32);
// It will print the final output
printf($c . " Celsius = " . $f . " Fahrenheit");
?>
Output
7 Celsius = 44.6 Fahrenheit
Explanation
In this given program, we take an input variable named $c
and its value is 7
to convert this into Fahrenheit.
Then we applied the standard formula of celsius to Fahrenheit conversion then which will return the converted value is 44.6
Fahrenheit.