php内部函数
2016-04-18 13:37
489 查看
strpos函数
View Code
/** haystack:被比较字串首地址(指向被比较字符串) needle:源字串首地址(指向源字符串) needle_len:源字符串长度 end:指向最后一个字符地址的下一个内存地址 **/ static inline char * zend_memnstr(char *haystack, char *needle, int needle_len, char *end) { char *p = haystack; //被比较字符串首地址 char ne = needle[needle_len-1]; //源字符串的最后一个字符 if (needle_len == 1) { return (char *)memchr(p, *needle, (end-p)); //返回被比较字符串第一次出现的地址 } if (needle_len > end-haystack) { //源字符串超过被比较字符串的长度 return NULL; } end -= needle_len; //end = end - needle_len //最后比较的位置 while (p <= end) { if ((p = (char *)memchr(p, *needle, (end-p+1))) && ne == p[needle_len-1]) { //比较首尾字符是否相等 if (!memcmp(needle, p, needle_len-1)) { //用来比较needle 和p 所指的内存区间前needle_len-1个字符 return p; } } if (p == NULL) { return NULL; } p++; } return NULL; }
View Code
相关文章推荐
- PHP做支付宝即时到账需注意
- 以 MAMP 为 Mac OS X 安装并设置 PHP开发环境
- windows下composer和yii2安装问题及解决办法
- 怎么安装phpcms?PHPCMS V9安装图文教程
- PHPCMS在MAC_OS环境下部署
- 利用LayoutParams.y设置组件跟随手指滑动时遇到的问题
- 关于PHP的!
- 关于PHP的urldecode与null
- 一致性哈希算法简单分析及php实现
- Thinkphp 事物问题
- matplotlib绘图基础
- 使用EditPlus和批处理删除文本重复内容行
- PHP语言 -- 投票练习题
- Laravel5 集合Collection
- 系统吞吐量(TPS)、用户并发量、性能测试概念和公式
- PHP实现快速排序
- php 获取提交来源,判断从哪里提交的
- PHP下利用PHPMailer配合QQ邮箱下的域名邮箱发送邮件
- php ++和逻辑运算的细节
- 每天laravel-20160718|Command-2