Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arithmetic in PHP

Status
Not open for further replies.

jmg498

Technical User
Oct 31, 2007
26
US
I'm not quite used to the syntax of performing arithmetic operations on variables in PHP. Below is my code. I think it's pretty obvious what I'm trying to do based on the code, but I just don't know how to format it correctly in PHP.

Any help is GREATLY appreciated! :) $temp is a variable passed in by a form.

<?php

if($temp > "271.16") {
$ratio == "12+2*(271.16-$temp)";
}
$ratio == "12+(271.16-$temp)";

print "The snow to liquid ratio is $ratio";

?>
 
Nevermind, figured it out!

<?php

if($temp > "271.16") {
$ratio = 12+2*(271.16-$temp);
}
$ratio = 12+(271.16-$temp);

print "The snow to liquid ratio is $ratio";

?>

This thread can be deleted. Thanks!
 
You don't need to put quotes around numbers. Your conditional still has them.

Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top