BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / www-technology / #8603同步于 2009/8/26
WWWTechnology机器人发帖

[合集] 那里错了?

dickfu
2009/8/26镜像同步0 回复
☆─────────────────────────────────────☆ shadan (shadan) 于 (Tue Jan 8 21:56:51 2008) 提到: $username = eregi_replace($bad_array[$m], "*", $username); 这个函数这么用那里错了? ☆─────────────────────────────────────☆ chit (chit) 于 (Tue Jan 8 22:02:02 2008) 提到: 你看一下官方的文档说明吧,你这个函数的区别就是不区分大小写 string ereg_replace ( string $pattern , string $replacement , string $string ) 本函数在 string 中扫描与 pattern 匹配的部分,并将其替换为 replacement 。 返回替换后的字符串。(如果没有可供替换的匹配项则会返回原字符串。) 如果 pattern 包含有括号内的子串,则 replacement 可以包含形如 \\digit 的子串,这些子串将被替换为数字表示的的第几个括号内的子串;\\0 则包含了字符串的整个内容。最多可以用九个子串。括号可以嵌套,此情形下以左圆括号来计算顺序。 如果未在 string 中找到匹配项,则 string 将原样返回。 例如,下面的代码片断输出 "This was a test" 三次: Example#1 ereg_replace() 例子 <?php $string = "This is a test"; echo str_replace(" is", " was", $string); echo ereg_replace("( )is", "\\1was", $string); echo ereg_replace("(( )is)", "\\2was", $string); ?> 要注意的一点是如果在 replacement 参数中使用了整数值,则可能得不到所期望的结果。这是因为 ereg_replace() 将把数字作为字符的序列值来解释并应用之。例如: Example#2 ereg_replace() 例子 <?php /* 不能产生出期望的结果 */ $num = 4; $string = "This string has four words."; $string = ereg_replace('four', $num, $string); echo $string; /* Output: 'This string has words.' */ /* 本例工作正常 */ $num = '4'; $string = "This string has four words."; $string = ereg_replace('four', $num, $string); echo $string; /* Output: 'This string has 4 words.' */ ?> Example#3 将 URL 替换为超连接 <?php $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text); ?> 【 在 shadan (shadan) 的大作中提到: 】 : $username = eregi_replace($bad_array[$m], "*", $username); : 这个函数这么用那里错了?
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。