Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Any one can explain to me? why it's returning 83?

<p>&lt;?php</p> <p>$k=0123;echo $k;</p> <p>?&gt;</p>

user-image
Question ajoutée par Kamatchi Panneer Selvam , Software Developer , Comtel General Trading LLC
Date de publication: 2014/10/13
Majid Hameed
par Majid Hameed , Senior Java Developer , Check24 Vergleichsportal GmbH

Yes anything that starts with0 is an octal integer.

If you don't want to store string and want to store number then following are2 options.

$k =0123.00;

OR if you want to stick with integer then you can do casting.

$k = (int)0123.00;

Yousef Adel Abdulaziz
par Yousef Adel Abdulaziz , Information Technology Specialist , Takamol Holding

Because it's assigning $k to the octal value of0123 which is83.

0123 =83 in octal

Instead, try to store0123 as a string e.g. $k = "0123";

Julfkar  Moh Umar
par Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited

This is OCTAL Number so this will be calculated as:

 

1*8^2+2*8^1+3*8^0 =

More Questions Like This