i have a problem with interger number in PHP
am 03.11.2007 18:37:58 von w2ajax
i have a problem with interger number in PHP
class read{
var $num;
function read($num){
$this->num = $num;
}
function basic(){
print "NUM: ".($this->num);
}
}
$read = new read(001002);
$read->basic(); // Output string: NUM: 514
?>
if i call
$read = new read(1001);
$read->basic();//Output string: NUM: 1001
// is true
who can explain me about problem?
I run this script on local with PHP 5.2.1
Re: i have a problem with interger number in PHP
am 03.11.2007 18:41:57 von Paul Herber
On Sat, 03 Nov 2007 17:37:58 -0000, "www.phpbasic.com"
wrote:
>i have a problem with interger number in PHP
>
>class read{
> var $num;
> function read($num){
> $this->num = $num;
> }
> function basic(){
> print "NUM: ".($this->num);
> }
>}
>$read = new read(001002);
>$read->basic(); // Output string: NUM: 514
001002 is an octal number.
and 001002 octal = 514 decimal
so remove any leading zeros first.
--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/ http://www.pherber.com/
Re: i have a problem with interger number in PHP
am 03.11.2007 18:44:02 von w2ajax
On Nov 4, 12:41 am, Paul Herber
wrote:
> On Sat, 03 Nov 2007 17:37:58 -0000, "www.phpbasic.com"
>
> wrote:
> >i have a problem with interger number in PHP
> >
> >class read{
> > var $num;
> > function read($num){
> > $this->num = $num;
> > }
> > function basic(){
> > print "NUM: ".($this->num);
> > }
> >}
> >$read = new read(001002);
> >$read->basic(); // Output string: NUM: 514
>
> 001002 is an octal number.
> and 001002 octal = 514 decimal
> so remove any leading zeros first.
>
> --
> Regards, Paul Herber, Sandrila Ltd.http://www.sandrila.co.uk/ http://www.pherber.com/
Thanks, Paul Herber