I need some help with Syntax on simplifying an equation in php (I have been using php for 3 days). In doing some research I have found that there may possibly be an easier way to code an equation. see existing code below:
<?php
$w = $_POST['weight'];
$h = $_POST['height'];
?>
Hi, Your BMI is <?php echo bcmul(bcdiv($w,bcpow($h,2,2),2),703,2); ?>
According to a comment on http://www.php.net/manual/en I can simply the code to: bc($w/($h)^2*703). However, I get an error message that function undefined. Is there an easier way to code this equation?
Why do you need the BC functions? Do you need arbitrary precision? If not (as most applications don’t), you can just do:
And if you need to get a certain number of decimals, look into PHP’s number_format(), for example: