Home  >  Article  >  Backend Development  >  How to convert Fahrenheit temperature to Celsius temperature in PHP

How to convert Fahrenheit temperature to Celsius temperature in PHP

藏色散人
藏色散人Original
2022-01-12 10:37:203450browse

php method to convert Fahrenheit temperature to Celsius temperature: 1. Create a PHP sample file; 2. Implement it through the conversion formula between Celsius temperature and Fahrenheit temperature "C = 5×(F-32)/9" Just convert.

How to convert Fahrenheit temperature to Celsius temperature in PHP

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to convert Fahrenheit temperature to Celsius temperature with php ?

The conversion formula between Celsius temperature (C) and Fahrenheit temperature (F) is:

C = 5×(F- 32)/9,F = 9×C /5+32

php conversion example is as follows:

<?php
 
//华氏温度οF
$hs=39;
 
//摄氏温度℃
$ss = (double)(($hs - 32) * 5) / 9;
 
//转换结果
print_r($ss);
//3.8888888888889
 
 
?>

Recommended study: "PHP video tutorial

The above is the detailed content of How to convert Fahrenheit temperature to Celsius temperature in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn