On Wednesday 24 October 2001 20:26, Michael George wrote:

[...]
> The function is called after a form submission from HTML.  When I enter
>       12      14
> I get:
> -----------------------------------------------------------------------
>-------- lookupProduct( 12, 14 )
>  $partNum: 12 does appear to be a number, and not a double
>   $serial: 14 does appear to be a number, and not a double
> -----------------------------------------------------------------------
>--------
>
> When I enter
>       12.5    14.8
> I get:
> -----------------------------------------------------------------------
>-------- lookupProduct( 12.5, 14.8 )
>  $partNum: 12 does appear to be a number, and not a double
>   $serial: 14 does appear to be a number, and not a double
> -----------------------------------------------------------------------
>--------
>
> Why is the function is_double() failing?  I have an analagous problem
> with the is_int() function.

You get both values as strings from the form. is_numeric checks if the 
variable is in some was a number (and returns true because it actually is 
a string representation of a number).
is_int and is_double check whether the variable's current datatype 
actually is "int" or "double"
See the manual.

Possible solution:
if (is_numeric ($a)) {
  $a = (double) $a;
  if (intval ($a) == $a) 
    echo "'$a' is integer";
  else
    echo "'$a' is double";
}

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

/* you are not expected to understand this */

- from the UNIX V6 kernel source

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to