开发者

Find substring or exact string in php

开发者 https://www.devze.com 2023-03-27 11:03 出处:网络
When I use strpos it returns false if the both string开发者_JAVA百科s are equal. Is there a function or a parameter to this function that returns tru if there is a substring in the main string or both

When I use strpos it returns false if the both string开发者_JAVA百科s are equal. Is there a function or a parameter to this function that returns tru if there is a substring in the main string or both strings are equal?

Or am i wrong and it does it for the full string also?


You are wrong - strpos() does not return false, it returns 0. Just do strpos() !== false to find out if it matched.


It isn't returning false, you're just not checking strict equality. Use === instead of ==, cause it found it at index 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消