Jay Blanchard wrote:
[snip]
naked
[/snip]
Dang John, I guess I don't think octally any more!
John writes out his grocery list in Hex. ;)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Why is this happening???
$id = 11;
echo $id; // Displays: 9
$id = 11;
echo $id; // Displays: 11
How do I make the first number (00011) display as 11? Why is it showing 9?
Thanks.
Monty
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
From: Monty [EMAIL PROTECTED]
$id = 11;
echo $id; // Displays: 9
$id = 11;
echo $id; // Displays: 11
How do I make the first number (00011) display as 11? Why is it showing 9?
Number values starting with a leading zero are assumed to be octal values.
Octal
[snip]
Why is this happening???
$id = 11;
echo $id; // Displays: 9
$id = 11;
echo $id; // Displays: 11
How do I make the first number (00011) display as 11? Why is it showing
9?
[/snip]
First of all you have naked numbers. The first one, 11, looks like
a
[snip]
naked
[/snip]
Dang John, I guess I don't think octally any more!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Wow, thanks John !
Number values starting with a leading zero are assumed to be octal values.
Octal 11 = Decimal 9
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
] Strange Numeric Conversion...
[snip]
Why is this happening???
$id = 11;
echo $id; // Displays: 9
$id = 11;
echo $id; // Displays: 11
How do I make the first number (00011) display as 11? Why is it showing
9?
[/snip]
First of all you have naked numbers. The first one
, 2 Apr 2004 15:38:03 -0600
To: Monty [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: [PHP] Strange Numeric Conversion...
[snip]
Why is this happening???
$id = 11;
echo $id; // Displays: 9
$id = 11;
echo $id; // Displays: 11
How do I make the first number (00011) display as 11? Why
no sense.
Monty.
From: [EMAIL PROTECTED] (Jay Blanchard)
Newsgroups: php.general
Date: Fri, 2 Apr 2004 15:38:03 -0600
To: Monty [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: [PHP] Strange Numeric Conversion...
[snip]
Why is this happening???
$id = 11;
echo $id; // Displays: 9
$id
]
Newsgroups: php.general
Date: Sat, 03 Apr 2004 00:01:43 +0200
To: [EMAIL PROTECTED]
Cc: Monty [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: [PHP] Strange Numeric Conversion...
sry... it's \\1 instead of //1 ... guess i had one to many beers :)
Red Wingate wrote:
trim will not work
Doesn't putting and x11 tell PHP it's a decimal format?
$id = 11;
$id2 = preg_replace(/^0+(.*)$/,\\1,$id);
echo $id2; // Displays 9
echo $id; // Displays 9 as well.
If the number begins with a zero, there seems to be no way to tell PHP
this
is an
hm
ever tryed telling PHP to display the variable as an integer?
echo (integer) $id ;
-- red
Daniel Clark wrote:
Doesn't putting and x11 tell PHP it's a decimal format?
$id = 11;
$id2 = preg_replace(/^0+(.*)$/,\\1,$id);
echo $id2; // Displays 9
echo $id;
Found this:
$a = 1234; # decimal number
$a = -123; # a negative number
$a = 0123; # octal number (equivalent to 83 decimal)
$a = 0x1A; # hexadecimal number (equivalent to 26 decimal)
http://www.phpbuilder.com/manual/language.types.integer.php#language.types.integer.casting
hm
ever tryed
* Thus wrote Daniel Clark ([EMAIL PROTECTED]):
Found this:
$a = 1234; # decimal number
$a = -123; # a negative number
$a = 0123; # octal number (equivalent to 83 decimal)
$a = 0x1A; # hexadecimal number (equivalent to 26 decimal)
$a is integer in all these cases, the only difference is the
* Thus wrote Monty ([EMAIL PROTECTED]):
I tried removing the zeros, but, I get the same result:
$id = 11;
$id = ltrim($id, '0');
echo $id; // Displays: 9 instead of 11 ???
This didn't work either:
$id = 11;
settype($id, 'string');
$id
Red Wingate wrote:
ever tryed telling PHP to display the variable as an integer?
echo (integer) $id ;
Ever tryed realizing 0x09, 011, and 9 are all integers (just different
bases)?
;)
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
Monty wrote:
Thanks Red, but, still the same problem:
$id = 11;
$id2 = preg_replace(/^0+(.*)$/,\\1,$id);
echo $id2; // Displays 9
echo $id; // Displays 9 as well.
If the number begins with a zero, there seems to be no way to tell PHP this
is an integer, not an
17 matches
Mail list logo