Why use !== FALSE to check stripos in php?

后端 未结 5 557
别跟我提以往
别跟我提以往 2020-12-10 11:32

Here is the code I am looking at.

foreach ($header as $idx => $field) {
    if (stripos($field, \'foo\') !== false) {
        $cols[\'foo\'] = $idx;
             


        
5条回答
  •  抹茶落季
    2020-12-10 12:15

    Because if the string matched at position 0, 0 evaluates to false, so you make sure to add the extra '=' so that type is taken in to consideration.

    strpos() returns false when NO match is found.

    Check out comparison operators.

提交回复
热议问题