我怎么把文本编辑器里面的假如:bb=<P> </P>
<TABLE cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR>
<TD vAlign=top width=657 colSpan=6>
<P align=center><B>贝川通讯录</B></P></TD></TR>
<TR>
<TD width=109>
<P align=left><B>办公室</B></P></TD>
这样的东西给转换成aa=<TABLE style="WIDTH: 506pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=674 border=0 x:str>这样保存到数据库,
这样转换的代码好有在保存到数据库的里面的aa在调取出来的时候在还原成页面形式?请高手赐教…………急急………………
<TABLE cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR>
<TD vAlign=top width=657 colSpan=6>
<P align=center><B>贝川通讯录</B></P></TD></TR>
<TR>
<TD width=109>
<P align=left><B>办公室</B></P></TD>
这样的东西给转换成aa=<TABLE style="WIDTH: 506pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=674 border=0 x:str>这样保存到数据库,
这样转换的代码好有在保存到数据库的里面的aa在调取出来的时候在还原成页面形式?请高手赐教…………急急………………
我怎么把文本编辑器里面的假如:
bb= <P> </P> <TABLE cellSpacing=0 cellPadding=0 border=1> <TBODY> <TR> <TD vAlign=top width=657 colSpan=6> <P align=center> <B>贝川通讯录 </B> </P> </TD> </TR> <TR> <TD width=109><P align=left> <B>办公室 </B> </P> </TD> bb转换成aa=<TABLE style="WIDTH: 506pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=674 border=0 x:str>将aa这样保存到数据库, 在保存到数据库的里面的aa在调取出来的时候在还原成页面形式的字符转换?请高手赐教…………急急………………
据特殊字符转成实体,用它就行了 html_entity_decode()所有字符转成实体
//存入的时候
$strTmp = ereg_replace('<', '<', $strTmp);
$strTmp = ereg_replace('>', '>', $strTmp);//取出的时候
$strTmp = ereg_replace('<', '<', $strTmp);
$strTmp = ereg_replace('>', '>', $strTmp);
htmlentities
是两个相反的函数.<?php
$str = "A 'quote' is <b>bold</b>";// 输出: A 'quote' is <b>bold</b>
echo htmlentities($str);// 输出: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
?>
<?php
$orig = "I'll \"walk\" the <b>dog</b> now";$a = htmlentities($orig);$b = html_entity_decode($a);echo $a; // I'll "walk" the <b>dog</b> nowecho $b; // I'll "walk" the <b>dog</b> now
// PHP 4.3.0 之前的版本将作如下处理
function unhtmlentities($string)
{
// 数値属性转换
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
// 字串属性转换
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}$c = unhtmlentities($a);echo $c; // I'll "walk" the <b>dog</b> now?>