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
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 o
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: http://www.php.n
* 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');
* 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 i
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 try
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;
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
>
evelopment
> Reply-To: [EMAIL PROTECTED]
> 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
f PHP sees this as an octal, then why does gettype(11) = INTEGER?
This
makes 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]>
Subjec
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
"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
>
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
[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
[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 bi
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 valu
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: ht
17 matches
Mail list logo