How to use strpos to determine if a string exists in input string?

后端 未结 7 1596
难免孤独
难免孤独 2020-12-03 17:17
$filename = \'my_upgrade(1).zip\';
$match = \'my_upgrade\';

if(!strpos($filename, $match))
    {
    die();
    }
else 
   {
   //proceed
   }

In

7条回答
  •  醉酒成梦
    2020-12-03 17:32

    strpos in this case will return a zero, which is then interpretted as false when you do the logical negation. You should check explicitly for the boolean false.

提交回复
热议问题