0

当我使用严格选项(我被认为是最好的选择,因为我正在将数字与数字进行比较)时,如果永远不会成真。但没有严格它工作正常!我只是在检查数组是否已经包含 post_id。如果不添加,如果是,则不添加重复项。

if (!in_array($post->ID, $cookie_value)) {  
    array_unshift($cookie_value, $post->ID);
}

print_r($cookie_value);

Array ( [0] => 25 [1] => 1 )

那么这里的交易是什么?

4

1 回答 1

0

Why use strict in the first place, especially if without strict it works just fine? If the string "2" is in the array, don't you want it to match the number 2? Unless your goal is to for example have both the string "2" and the number 2 in the array

There are very few times where I care about what type PHP thinks a variable is. The way PHP implements type juggling, I usually don't have to care.

I don't think you want to use strict.

于 2013-02-03T03:12:04.750 回答