At 03:41 PM 8/28/01 , scott [gts] wrote:
>my understanding is that numeric is a broad term for
>number values (any value with only numbers and a
>decimal point) like 1, 5.6, 332, 0.5532, for example.
>
>integers are a sub-set of numerics, so any integer is
>a numeric value, but any numeric value i
seb
-Original Message-
From: Philip Olson [mailto:[EMAIL PROTECTED]]
Sent: 28 August 2001 22:44
To: [EMAIL PROTECTED]
Subject: [PHP] is_numeric for php3
hi friends,
Can someone post here "the" most efficient method to validate a variable
as numeric? I see a ton of hacks
e
> > list ($x, $y) = split("\.", $number);
> >
> > // if there's no decimal value
> > if ( empty($y) ) {
> > return is_int($x);
> > }
> > else {
> > return ( is_int($x) && is_int($y) );
> > }
> >
>
ECTED]]
> Subject: Re: [PHP] is_numeric for php3
>
> Hi Philip,
>
> By definition, any string that does not contain
> alpha-characters is numeric. I mean, '123' is an
> integer, if only because it isn't 'onetwothree', you
> know?
--
PHP Gen
a few months to fully understand them
and get over regexp-heebie-jeebies of my own.
> -Original Message-
> From: daniel james [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 28, 2001 6:42 PM
> To: scott [gts]; php
> Subject: RE: [PHP] is_numeric for php3
>
>
&g
e
> if ( empty($y) ) {
> return is_int($x);
> }
> else {
> return ( is_int($x) && is_int($y) );
> }
>
> }
>
>
> > -Original Message-
> > From: daniel james [mailto:[EMAIL PROTECTED]]
> > Subject: Re: [PHP] is_numeric
split("\.", $number);
// if there's no decimal value
if ( empty($y) ) {
return is_int($x);
}
else {
return ( is_int($x) && is_int($y) );
}
}
> -Original Message-
> From: daniel james [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP
Hi Philip,
By definition, any string that does not contain
alpha-characters is numeric. I mean, '123' is an
integer, if only because it isn't 'onetwothree', you
know?
Because if I do this:
$num1 = '123';
$num2 = '456';
$total = $num1 + $num2;
print($total);
the total is going to be 579. You
Hi Daniel,
No, I mean if it's numeric, not neccesarily an integer. As the following
is numeric and not an integer but rather, a string :
$num = '123';
Anyone have an authoritative answer on this? Like, something that would
go in the manual as the official php3 is_numeric check?
Regards,
do you mean, as in,
if !is_integer($var) {
print("$var is not an integer");
}
--- Philip Olson <[EMAIL PROTECTED]> wrote:
> hi friends,
>
> Can someone post here "the" most efficient method to
> validate a variable
> as numeric? I see a ton of hacks/ways in the manual
> user comments under
> i
hi friends,
Can someone post here "the" most efficient method to validate a variable
as numeric? I see a ton of hacks/ways in the manual user comments under
is_int, is_integer and is_numeric and would like to see just one or two
good solid ones. And please, no regular expressions :)
Regards,
P
11 matches
Mail list logo