<?php
/*
Title: Temperature Conversion
Description: Convert celsius to fahrenheit and
fahrenheit to celsius.
Author: Murray Moffatt for A Web 4 U Designs
History:
2005-03-15 : Initial coding.
*/
function temp2celsius ($fahrenheit, $precision = 0) {
// Convert the supplied temperature in celsius to
// fahrenheit and return the value. Specify the required
// precision to round the converted value to.
// Returns FALSE on error.
if (!isset($fahrenheit)) return FALSE;
$precision = (integer)$precision;
$celsius = (float)(($fahrenheit - 32) / 1.8 );
return round($celsius, $precision);
}
function temp2fahrenheit ($celsius, $precision = 0) {
// Convert the supplied temperature in fahrenheit to
// celsius and return the value. Specify the required
// precision to round the converted value to.
// Returns FALSE on error.
if (!isset($celsius)) return FALSE;
$precision = (integer)$precision;
$fahrenheit = (float)(1.8 * $celsius) + 32;
return round($fahrenheit, $precision);
}
echo "<p>50F is " . temp2celsius(50) . "C</p>";
echo "<p>50C is " . temp2fahrenheit(50) . "F</p>";
?>
Reverse a given number Categories : PHP , Beginner Guides , Algorithms , Math. mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP , Beginner Guides , MySQL , HTML and PHP , Databases Automatic global variable definer Categories : PHP , Variables , Beginner Guides A beginner's session handling class Categories : PHP , PHP Classes , Sessions , Beginner Guides grab the result of any calculation you submit to the Google Calculator. Categories : PHP , Arrays , Web Services , Regexps , Math. Newbie Notes #3 - What went wrong? A useful little debugging aid Categories : PHP , Beginner Guides , Debugging Form Validation Using PHP to highlight non valid fields Categories : PHP , Form Processing , Data Validation , Beginner Guides a PHP Function to Get only the filename (remove the extension) using regular expressions. Categories : PHP , Regexps , Beginner Guides Form Submission Using Array's Categories : PHP , HTML and PHP , Beginner Guides , Arrays Simple Cookie example Categories : PHP , Beginner Guides , Cookies Specify your connection settings and create a link to a MySQL database. Categories : PHP , PHP Classes , Databases , MySQL , Beginner Guides Link Submition - Allow your visitors to submit links to the site. Categories : PHP , Arrays , Filesystem , Beginner Guides Upload Via FTP - an alternative to move_uploaded_file Categories : PHP , FTP , Beginner Guides Script loading time Categories : PHP , Beginner Guides , Date Time Basic Authentication with sessions Categories : PHP , Beginner Guides , Authentication , Form Processing , Sessions