为什么替换不了呢?
$str = "有几个文件:index.php,style.css, action.js"; $p = '/\w+\.\w+/i'; $replace = '<em>$0</em>'; $str = preg_replace($p, $replace, $str); echo $str; 结果还是原字符串:"有几个文件:index.php,style.css, action.js"
$str = "有几个文件:index.php,style.css, action.js"; $p = '/\w+\.\w+/i'; $replace = '<em>$0</em>'; $str = preg_replace($p, $replace, $str); echo $str; 结果还是原字符串:"有几个文件:index.php,style.css, action.js"
2017-09-10
举报