wap开发特殊字符处理

一直都发现这个问题了,写心情时,如果写&会出错,写$会不显示!

wap特殊字符处理函数:

<?php

function unhtml($content)
{
$content=str_replace("&","&amp;",$content);
$content=str_replace("<","&lt;",$content);
$content=str_replace(">","&gt;",$content);
$content=str_replace(chr(13),"<br>",$content);
$content=str_replace("","",$content);
$content=str_replace("$","$$",$content);
$content=str_replace("我日","不文明用语",$content);
$content=str_replace(chr(34),""",$content);
/*
$content=str_replace(" ","&nbsp;",$content);
$content=str_replace("[emt]","<img src=images/xyq/",$content);
$content=str_replace("[/emt]",".gif/>",$content);
*/
return $content;
}

echo unhtml($row["content"]);
?>

 

asp版处理:

<%
content=replace(rs("content"),"&","&amp;")
content=replace(content,"<","&lt;")
content=replace(content,">","&gt;")
content=replace(content,chr(13),"<br>")
content=replace(content,"","")
content=replace(content,"$","$$")
content=replace(content,"我日","不文明用语")
content=replace(content,chr(34),"""")
response.write content
%>
 

    A+
发布日期:2009年04月21日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: