Which method is preferred strstr or strpos?
问题 I noticed a lot of developers are using both strstr and strpos to check for a substring existence. Is one of them preferred and why ? 回答1: From the PHP online manual: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead. 回答2: Here are some other answers (+benchmarks) I got to my question, which is almost the same (I didn't realize yours when asking). In the meantime I also made my own benchmark test,