str_replace()、preg_replace()、strtr()三者的区别和用法,采集相关

php中在字符串的替换模块有3个函数,str_replace(),preg_replace(),以及strtr()。在编程过程中,这三个函数的执行效率有所不同,str_replace()函数比preg_replace()函数执行效率快,而strtr()函数的执行效率又高于str_replace(),所以在变成中建议使用strtr()函数。

str_replace() 函数以其他字符替换字符串中的一些字符(区分大小写)。str_replace(find,replace,string,count)
preg_replace ()用于执行一个正则表达式的搜索和替换,一般很少使用 .mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
strtr() 函数转换字符串中特定的字符。strtr(string,from,to)
微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_1006.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?