一个奇怪的现象?求解!!不解!大家帮忙 asp里有:<textarea><%=Server.HTMLEncode(rs("content"))%></textarea>不知道php里是否有类似的方法。也可以直接自己替换把<替换成<等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将从TEXTAREA中取出的内容用htmlspecialchars算一下就OK了。 方法又很多,你可以自己写一个替调违法字符的函数,也可以用PHP自带的,如楼上所说,只要在插入数据库之前用函数处理一下就行了!//剔除非法的字符function delscript($word){for($j=0;$j<strlen($word);$j++){if(substr($word,$j,1)=="<")$word=substr($word,0,$j)."<".substr($word,$j+1);}for($j=0;$j<strlen($word);$j++){if(substr($word,$j,1)==">")$word=substr($word,0,$j).">".substr($word,$j+1);}for($j=0;$j<strlen($word);$j++){if(ord(substr($word,$j,1))==13)$word=substr($word,0,$j)."<br>".substr($word,$j+2);}return $word;} 楼主可以参考以下代码<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form><textarea rows="27" name="test" cols="80"><?php$str="<textarea>abc</textarea>";$str_out=htmlspecialchars($str);echo $str_out;?></textarea></form></body></html> 帮我看下这句随机sql语句怎么优化 php_curl无法载入的问题 关于img 正则 自己写了个图片上传,有代码,怎么成功不了,在线等...... IIS+PHP连接sqlserver问题!!!急急急 【求救】关于linux下Smarty写缓存文件的问题 mysql 问题 解题都100 分 公司发展需要,招PHP程序员2名(武汉) 求简单实用的在线编辑器, 2000服务器装上php安装php程序不能下一步是为什么? 请问如何把"替换成* 急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急
//剔除非法的字符
function delscript($word)
{
for($j=0;$j<strlen($word);$j++){
if(substr($word,$j,1)=="<")$word=substr($word,0,$j)."<".substr($word,$j+1);
}
for($j=0;$j<strlen($word);$j++){
if(substr($word,$j,1)==">")$word=substr($word,0,$j).">".substr($word,$j+1);
}
for($j=0;$j<strlen($word);$j++){
if(ord(substr($word,$j,1))==13)$word=substr($word,0,$j)."<br>".substr($word,$j+2);
}
return $word;
}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><form>
<textarea rows="27" name="test" cols="80">
<?php
$str="<textarea>abc</textarea>";
$str_out=htmlspecialchars($str);
echo $str_out;
?>
</textarea>
</form></body>
</html>