note 88974 added to function.is-int

From: Date: Mon, 16 Feb 2009 19:09:19 +0000
Subject: note 88974 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-150727@lists.php.net to get a copy of this message
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>'; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 78.2.72.146 ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit -- https://master.php.net/note/edit/88974 Del: integrated -- https://master.php.net/note/delete/88974/integrated Del: useless -- https://master.php.net/note/delete/88974/useless Del: bad code -- https://master.php.net/note/delete/88974/bad+code Del: spam -- https://master.php.net/note/delete/88974/spam Del: non-english -- https://master.php.net/note/delete/88974/non-english Del: in docs -- https://master.php.net/note/delete/88974/in+docs Del: other reasons-- https://master.php.net/note/delete/88974 Reject -- https://master.php.net/note/reject/88974 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150727) next »