php strncmp函数原型源码分析

2023-12-08 0 344
目录
  • strncmp
    • 函数原型
  • 源码分析 版本PHP 5.6.40
    • 1、Zend/zend_builtin_functions.c (内置函数)
    • 2、Zend/zend_operators.c
    • 3、memcmp 用法

strncmp

函数原型

php strncmp函数原型源码分析

源码分析 版本PHP 5.6.40

1、Zend/zend_builtin_functions.c (内置函数)

ZEND_FUNCTION(strncmp)
{
char *s1, *s2;
int s1_len, s2_len;
long len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \”ssl\”, &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) {
return;
}
if (len < 0) {
zend_error(E_WARNING, \”Length must be greater than or equal to 0\”);
RETURN_FALSE;
}
RETURN_LONG(zend_binary_strncmp(s1, s1_len, s2, s2_len, len));
}

2、Zend/zend_operators.c

ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
{
int retval;
if (s1 == s2) {
return 0;
}
retval = memcmp(s1, s2, MIN(length, MIN(len1, len2)));
if (!retval) {
return (MIN(length, len1) – MIN(length, len2));
} else {
return retval;
}
}

3、memcmp 用法

php strncmp函数原型源码分析

以上就是php strncmp函数原型源码分析的详细内容,更多关于php strncmp源码分析的资料请关注悠久资源网其它相关文章!

您可能感兴趣的文章:

  • PHP中strncmp()函数比较两个字符串前2个字符是否相等的方法
  • php实现商城购物车的思路和源码分析
  • php源码分析之DZX1.5随机数函数random用法
  • PHP strtotime函数用法、实现原理和源码分析

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 PHP php strncmp函数原型源码分析 https://www.u-9.cn/biancheng/php/128223.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务