首选使用strstr或strpos哪种方法? [英] Which method is preferred strstr or strpos?

查看:109
本文介绍了首选使用strstr或strpos哪种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到许多开发人员同时使用strstr和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 ?

推荐答案

从PHP 在线手册:

如果您只想确定 特定的针头发生在 干草堆,使用更快,更少 内存密集型功能 strpos() 代替.

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

这篇关于首选使用strstr或strpos哪种方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆