Friday, July 31, 2009

Can someone please help me make a short and quick PHP code?

I am not really good at PHP, but I have 1 code that works:





if ($operation =="multiply")


{


$product =$firstnumber * $secondnumber;


echo ($firstnumber." * ".$secondnumber." = ".$product);





Now I want to make one that squares instead of multiply, so can someone help me build one?





Thank you in advance!

Can someone please help me make a short and quick PHP code?
I agree with the last poster, that's the quickest way to do it...but given that you only want to square...








if ($operation=="square")





{


$result=$number*$number;








echo $result;








}
Reply:if ($operation =="sqrt")


{


$product =sqrt $firstnumber;


echo (" The square root of ".$firstnumber." = ".$product);





This might work, IDK??!
Reply:Use the pow math function:





%26lt;?php


echo pow(4,2) . "
";


echo pow(6,2) . "
";


echo pow(-6,2) . "
";


echo pow(-6,-2) . "
";


echo pow(-6,5.5);


?%26gt;


No comments:

Post a Comment