If string contains forward slash

前端 未结 3 508
一个人的身影
一个人的身影 2021-01-04 07:43

How do i make a if statement which checks if the string contains a forward slash?

$string = \"Test/Test\";   
if($string .......)
{
    mysql_query(\"\"); 
}         


        
3条回答
  •  一生所求
    2021-01-04 08:49

    if(strpos($string, '/') !== false) {
      // string contains /
    }
    

    From the PHP manual of strstr:

    Note:

    If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.

提交回复
热议问题