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

后端 未结 7 1554
难免孤独
难免孤独 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:51
    false === strpos($filename, $match)
    

    The strpos functionDocs returns false if not found or 0 if found on position 0 (programmers like to start counting at 0 often):

    Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

    0 讨论(0)
提交回复
热议问题