PHP forward slash match

前端 未结 2 1293
孤城傲影
孤城傲影 2021-01-15 04:36

How I can check if some string contains forward slash in PHP?

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 05:14

    Check for occurences with strpos()

    if (strpos($string, '/') !== FALSE) // Found
    

    Returns the position as an integer. If needle is not found, strpos() will return boolean FALSE.

    This is faster than a regular expression, and most other methods, because it stops checking at the first occurrence.

提交回复
热议问题