SMILET
\\php-7.1.0\\ext\\standard\\string.c line:4091
PHP_FUNCTION(str_replace)
/* Phpstorm中的方法定义实际是加载了一个php文件,以供IDE建立函数索引,该文件列出了各函数定义及参数
实际方法的实现需要阅读源码 */
// 核心函数:
#define php_memnstr zend_memnstr
static zend_always_inline const char *
zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const char *end)
// 功能:在字符串中搜索needle出现的位置
static zend_string *php_str_to_str_ex(zend_string *haystack,
char *needle, size_t needle_len, char *str, size_t str_len, zend_long *replace_count)
static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack,
zend_string *needle, char *str, size_t str_len, zend_long *replace_count)
// 功能:在haystack中搜索needle,并将其替换为str,i版本为大小写不敏感
static zend_string* php_char_to_str_ex(zend_string *str, char from, char *to, size_t to_len, int case_sensitivity, zend_long *replace_count)
// 功能:将单字符search替换为目标repalce
static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *subject, zval *result, int case_sensitivity)
// 功能:将subject中的search字符串替换为replace字符串,并返回替换次数