亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php in_array What's going on?
PHPz
PHPz 2017-06-06 09:53:41
0
3
1167
<?php
function test($a="all"){
    var_dump(in_array($a,array(0,1)));
}

test("all");

test(1);

Return two true

PHPz
PHPz

學(xué)習(xí)是最好的投資!

reply all(3)
小葫蘆

bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )

- 如果第三個參數(shù) strict 的值為 TRUE 則 in_array() 函數(shù)還會檢查 needle 的類型是否和 haystack 中的相同。

You need to use the third parameter.

Ty80

PHP is a weakly typed language and will automatically convert variable types according to specific scenarios. The arrays you want to search are obviously all integers, so you can only convert the variables into integers. When pure characters are converted into integers, 0 is naturally included.

我想大聲告訴你

This is because there is a problem with converting strings to digits. var_dump('d'==0); true pure characters will be converted to 0

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template