', '', $"/> ', '', $">
Home > Backend Development > PHP Tutorial > 请问一个preg_replace的奇怪有关问题

请问一个preg_replace的奇怪有关问题

WBOY
Release: 2016-06-13 10:20:09
Original
754 people have browsed it

请教一个preg_replace的奇怪问题。
我需要在一个html文档中将 这样的标签,替换成

,用的语句是这样的:

$demo = "abc
def" ;
$demo = preg_replace('', '

', $demo);

最后demo结果为 "abc > def"

怎么多出一对尖括号了呢?

但是同样的方法,使用ereg_replace就正常了:
$demo = "abc
def" ;
$demo = ereg_replace('', '

', $demo);
demo输出:"abc

def"

听说php以后会淘汰掉ereg_replace,但是我这个功能preg_replace老是莫名其妙在外边多出一对尖括号,我好郁闷呀!

为什么呀?

------解决方案--------------------
$demo = preg_replace('##', '

', $demo);


你的 '', '

' 是将作为定界符用的
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template