当前位置: 代码网 > it编程>编程语言>Php > php strncmp函数原型源码分析

php strncmp函数原型源码分析

2024年05月19日 Php 我要评论
strncmp函数原型源码分析 版本php 5.6.401、zend/zend_builtin_functions.c (内置函数)zend_function(strncmp){ char *s

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源码分析的资料请关注代码网其它相关文章!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com