Röportaj soru: php yılında 123 == 0123 nedir?

6 Cevap php

Ben yanlış cevap var. o yüzden sordum? i cevap veremedi. Herkes cevap yapabilir miyim? Bunu öğrenmek çok ilgileniyorum.

6 Cevap

Ile bir numara önek 0 sekizli (8 tabanı), çok aynı şekilde gösterir 0x hex (baz 16) gösterir.

Bu kod:

var_dump(123);
var_dump(0123);

alacak:

int 123
int 83

123 ondalık iken 0123, sekizlik notaları (because of the 0 at the begining) çünkü bu.


For more informations, you can take a look at the Integer section of the manual.


An even trickier question would have been to ask about 79 and 079, for instance :

var_dump(79);
var_dump(079);

alacak:

int 79
int 7

(9 is not a valid digit in octal ;-) )

1) When we use == operator in php, it checks if values are equal. So 5=="5" => true 2) When we use === operator in php, it checks if values and data types are equal. So 5==="5" => false

123==0123 => false ALSO 123 === 0123 => false

123 is decimal number : 123 0123 is an octal number (as it starts with 0) : 83

123 83 eşit değildir

0123 ondalık 83 olduğunu, "sekizli (8 tabanı) in 123" anlamına geliyor.

123 ondalık bir sayıdır iken 0123, (kafamın üst kapalı 83 ondalık) sekizlik bir sayı için gösterim. Bu nedenle, eşit değildir.

0 sekizli (8 tabanı), 0x hex (baz 16) gösterir kadar aynı şekilde gösterir.

see More php interview questions