Can somebody explain me why is this happening?
$value = 12.3;
$number = intval($value);
echo Number: $number, Value: $valuebr;
// echoes: Number: 12, Value: 12.3
if ($number != $value) {
echo Bad;
} else {
echo Good; // echoes Good!!
}
The previous should be echoing Bad. (I
* Thus wrote Cesar Cordovez ([EMAIL PROTECTED]):
Can somebody explain me why is this happening?
$value = 12.3;
$number = intval($value);
echo Number: $number, Value: $valuebr;
// echoes: Number: 12, Value: 12.3
I'm guessing you wondering why the .3 is removed. Thats because
12.3 isn't
What versio of php? I get Bad (which is good ;)
Cesar Cordovez wrote:
Can somebody explain me why is this happening?
$value = 12.3;
$number = intval($value);
echo Number: $number, Value: $valuebr;
// echoes: Number: 12, Value: 12.3
if ($number != $value) {
echo Bad;
} else {
echo Good;
Curt:
My fault! You are right, but thats not what I want. $value comes from a
form filled by a user. I want $value to be an integer. Not a float.
So if the user types 12.3 the system has to send an error msg.
Therefore the procedure.
By-the-way, Im using PHP 4.3.3 (on windows XP
* Thus wrote Cesar Cordovez ([EMAIL PROTECTED]):
Curt:
My fault! You are right, but thats not what I want. $value comes from a
form filled by a user. I want $value to be an integer. Not a float.
So if the user types 12.3 the system has to send an error msg.
Yeah, after reading merek's
The other purpose of this procedure is if the user types 12asdasd into
$value, $number will be assigned 12 so $value and $number are not the
same, meaning $value is not a number. Which is correct, but the
procedure is not working correctly in PHP when it should. (It works in
c, c++, fortran
This is getting weird by the minute. I changed the script:
if ($number != $value) {
echo Bad;
} else {
echo Good; // echoes Good!!
}
to:
($number != $value)
($number !== $value)
($number === $value)
and I get the Good stuff...
At this point, I think I have to change the
why don't you use this??
http://it.php.net/manual/it/function.is-integer.php
Cesar Cordovez ha scritto:
This is getting weird by the minute. I changed the script:
if ($number != $value) {
echo Bad;
} else {
echo Good; // echoes Good!!
}
to:
($number != $value)
($number !==
This should be reported as a bug.
I tried few searches and I got
Warning: mysql_fetch_array(): 9 is not a valid MySQL result resource in
/local/Web/sites/php-bugs-web/search.php on line 182
on bugs.php.net
Cesar Cordovez wrote:
This is getting weird by the minute. I changed the script:
if
Because is_integer(12thisisnotanumber) retuns true.
Andrea Pinnisi wrote:
why don't you use this??
http://it.php.net/manual/it/function.is-integer.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Thu, 2003-10-23 at 11:41, Cesar Cordovez wrote:
Because is_integer(12thisisnotanumber) retuns true.
Not for me it doesn't. Returns false. Prolly because it's a string. Even
the following returns false for me:
is_integer(12)
Cheers,
Rob.
--
On Thu, 2003-10-23 at 11:21, Cesar Cordovez wrote:
At this point, I think I have to change the procedure. This is not
good. Any sugestions on how to now if the user types an integer number
in a field?
Here's a really simple way:
if( ereg( '^[[:space:]]*[[:digit:]]+[[:space:]]*',
On Thu, 2003-10-23 at 11:51, Robert Cummings wrote:
On Thu, 2003-10-23 at 11:21, Cesar Cordovez wrote:
At this point, I think I have to change the procedure. This is not
good. Any sugestions on how to now if the user types an integer number
in a field?
Here's a really simple
Sorry, typo, this is what I meant,
!is_integer(12thisisnotanumber) retuns true.
but also,
is_integer(12) return false.
therefore,
is_integer(12) return true.
So, how can I check if what ever the user writes is an integer or not,
knowing that he will write it in a string field.
Any how, I
* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]):
This should be reported as a bug.
I tried few searches and I got
Warning: mysql_fetch_array(): 9 is not a valid MySQL result resource in
/local/Web/sites/php-bugs-web/search.php on line 182
The search seems to work now, what did you
Hello all,
http://www.php.net/is_numeric
is the function you are looking for. No need for fancy regexps.
Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org
Cesar Cordovez wrote:
Sorry, typo, this is what I meant,
!is_integer(12thisisnotanumber) retuns true.
but also,
is_integer(12) return
Status: All
Return only bugs in categories: Scripting Engine Problem
Return bugs with operating system: windows
But it is ok now.
Curt Zirzow wrote:
* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]):
This should be reported as a bug.
I tried few searches and I got
Warning: mysql_fetch_array():
Cesar,
You can take a look into is_numeric () (http://www.php.net/is_numeric).
It will tell you whether the value is a number or a numeric string, but
it will also return true if the value is a float. However, at that point
you know your working with the right type of variable.
Jordan S.
Greg Beaver wrote:
http://www.php.net/is_numeric
is the function you are looking for. No need for fancy regexps.
The OP is looking for an integer, but is_numeric() will return true for
float values and also for numbers in scientific notation. So 12.3 and
12E3 will be TRUE.
The original
These are all workarounds around the real problem. If php gets it wrong
fix php.
Robert Sedlacek wrote:
On Thu, 23 Oct 2003 11:59:44 -0400, Cesar Cordovez wrote:
So, how can I check if what ever the user writes is an integer or not,
knowing that he will write it in a string field.
Idea:
On Thu, 2003-10-23 at 12:28, Greg Beaver wrote:
Hello all,
http://www.php.net/is_numeric
is the function you are looking for. No need for fancy regexps.
Sorry, that doesn't cut it. He want's integers not floats, and I'm also
sure he doesn't want exponential notation to pass either.
On Thu, 2003-10-23 at 12:43, Marek Kilimajer wrote:
These are all workarounds around the real problem. If php gets it wrong
fix php.
Could you explain how PHP has it wrong?
Rob.
--
..
| InterJinn Application Framework -
On Thu, 2003-10-23 at 12:41, John W. Holmes wrote:
Greg Beaver wrote:
http://www.php.net/is_numeric
is the function you are looking for. No need for fancy regexps.
The OP is looking for an integer, but is_numeric() will return true for
float values and also for numbers in
This echoes out Bad on my LAMP server as it should, but Good on
Cesar's windows server:
$value = 12.3;
$number = intval($value);
echo Number: $number, Value: $valuebr;
// echoes: Number: 12, Value: 12.3
if ($number != $value) {
echo Bad;
} else {
echo Good; // echoes Good!!
}
On Thu, 2003-10-23 at 13:01, Marek Kilimajer wrote:
This echoes out Bad on my LAMP server as it should, but Good on
Cesar's windows server:
Aaaah how true. I wasn't following this much earlier so I don't know if
he is using the most up to date version, in which case it may already be
fixed.
Everybody:
This problem solved. It is not PHP's fault, It is mine. When I fixed
some problems that I thought where non intrusive in this problem,
everything started working as a charm.
Here is the finished function, it is part of a class called xValidate.
function integer($msg, $prompt,
I got the error again:
http://bugs.php.net/search.php?search_for=boolean=0limit=10order_by=direction=ASCcmd=displaystatus=Allbug_type%5B%5D=Scripting+Engine+problemphp_os=windowsphpver=assign=author_email=bug_age=0
Curt Zirzow wrote:
* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]):
This should
* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]):
I got the error again:
http://bugs.php.net/search.php?search_for=boolean=0limit=10order_by=direction=ASCcmd=displaystatus=Allbug_type%5B%5D=Scripting+Engine+problemphp_os=windowsphpver=assign=author_email=bug_age=0
That reminds me of the time
28 matches
Mail list logo