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)); }
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; } }
以上就是php strncmp函数原型源码分析的详细内容,更多关于php strncmp源码分析的资料请关注插件窝其它相关文章!