+ 2

Hi, Why the output is 24, step by step write please?

<? php echo intval ('30', 8); ? >

25th Jul 2019, 1:12 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
5 Answers
+ 5
EGO it's decimal to octal conversion where $var is first statement which is $var is the scalar value being converted to an integer and second value is the base for the conversion as there is no 0 or 0X in the intval('30',8) that shows the given string is given in decimal and we want to convert it in the octal as written in intval() <?php $var = "30"; echo intval($var)."\n".intval($var, 8); ?> So in this decimal to octal conversion is perform on 30 So 30= 3×8^1 + 0×8^0 = 24+0=24 so output is 24
25th Jul 2019, 1:27 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 3
egxcuse me, there's quotes needed on 30.
25th Jul 2019, 1:23 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
+ 3
Thank You very much, STEASY_:-)
25th Jul 2019, 1:31 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
+ 1
My Output is 30.... Is there any extra code?
25th Jul 2019, 1:16 PM
Julian Dörling
Julian Dörling - avatar
0
đŸ€”
25th Jul 2019, 3:46 PM
Thiago Isac Torres
Thiago Isac Torres - avatar