note 88974 rejected from function.is-int by danbrown
| From: | danbrown@php.net | Date: | Mon, 16 Feb 2009 19:23:37 +0000 |
| Subject: | note 88974 rejected from function.is-int by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150728@lists.php.net to get a copy of this message | ||
Note Submitter: mirelamajnaric at gmail dot com
----
I'm a php beginner, and I could use some help with this exercise. The user enters two values in
textfields (htm) and php has to check if the entered values are numbers, type integer. If they are,
then the hypotenuse is calculated (using Pythagorean theorem). Without the if/else part it works
just fine, but when I add the test if the values are integer, it alwas returns the body of the if
function.
Help please...
<?php
function pitagora($k1,$k2)
{
$h=sqrt(($k1*$k1)+($k2*$k2));
return $h;
}
$a=$_POST['a'];
$b=$_POST['b'];
if(!is_int($a) || !is_int($b))
{
echo 'The values you entered are not Integer. <br><br>';
echo '<a href="pitagoraFunkcija.htm">Backk</a> to previous page.';
}
else
{
echo 'The side a='.$a.'. The side b='.$b.'.<br><br>';
echo 'The hypotenuse c='.pitagora($a,$b).'.<br>';
}
?>