Forum Moderators: coopster
<? php
$q = 360/$_POST['thenumber'];
$z= round(float log(float$q [, 2]));
?>
$_POST['thenumber'] is a number from a form passed to a current page
I need to divide 360 by 'thenumber'
returned $q variable to be used in logarthmic calculation - base 2
$z variable to be the whole number only (to be used in another part of the script)
Any assistance much appreciated.
looks like a syntax issue
$q = 360/$_POST['thenumber'];
$z= round(float log(float$q [, 2]));
you shouldn't need to typecast those numbers. I also imagine you are copying the syntax from the manual. You don't need those floats. They are just telling you what type is expected or returned. Also the square brackets mean that it is an optional param in the function call.
It should look something like this
$q = 360/$_POST['thenumber'];
$z= round(log($q,2));
try that and see what happens
$q = 360/$_POST['thenumber'];
$z= round(log($q,2));
When you go to php.net and look at function definitions, there's a few things you have to know ;). The "float" that stood before the variable's name means that the variable must be of the type float. (See [php.net...] for more infos about types) You must not actually write this when you call a function.
Same for the brackets. They mean that the parameter inside them is optional. You have to write this parameter when you call the function only if you want its value to be different than the default one. Once, again, the brackets should not remain there.
Hope it makes things a little clearer.