转义字符的问题。 $str = str_replace("\", """,$str); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $tt = str_replace('"','"',$tt); 这两种有什么区别,能帮我解释一下嘛?$tt = str_replace('"','"',$tt); $str = str_replace("\", """,$str); 这两种有什么区别,能帮我解释一下嘛?$tt = str_replace('"','"',$tt); $str = str_replace("\", """,$str);-===========================没区别吧。 $a = addslashes($string);$a = stripslashes($string); echo $re["name"];$t->setvar("name",stripslashes($re["name"]));输出的name是:Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15\" 256MB 40GB Combo WinXP Pro Notebook 但是,给了文本框,文本框却还是到"引号之前,引号之后的就没了。<input name="name" type="text" id="name2" value="{name}" >为什么嘛?? 引号呢?<input type=text value = 'Sony VAIO V505 PCG-V505DC1PC 12.1" Notebook Computer'>标准的写法是<input type=text value = "Sony VAIO V505 PCG-V505DC1PC 12.1" Notebook Computer"> function decodeHtmlChar($value) { $tt = $value; $tt = str_replace('','amp;',$tt); $tt = str_replace("'",''',$tt); $tt = str_replace('"','"',$tt); $tt = str_replace('<','<',$tt); $tt = str_replace('>','>',$tt); return $tt; }///////////////////////////////echo $re["name"];echo "<br>";echo stripslashes($re["name"]);echo "<br>";echo decodeHtmlChar($re["name"]);结果Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15\" 256MB 40GB Combo WinXP Pro NotebookToshiba Satellite PSA60U-02201D Cel 2.8GHz 15" 256MB 40GB Combo WinXP Pro NotebookToshiba Satellite PSA60U-02201D Cel 2.8GHz 15\" 256MB 40GB Combo WinXP Pro Notebook 可是文框内却是Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15引号怎么不会变成"???? 我知道了我把<input name="name" type="text" id="name2" value="{name}" >改成<input name="name" type="text" id="name2" value='{name}'>文本框内就显示出所有的来了。可是,我不想这样改。。不要改这个。而是通过name传过来的值就可以用。怎么办? 我知道了,,,我把原来的function decodeHtmlChar($value) { $tt = $value; $tt = str_replace('amp;','',$tt); $tt = str_replace(''',"'",$tt); $tt = str_replace('"','"',$tt); $tt = str_replace('<','<',$tt); $tt = str_replace('>','>',$tt); return $tt; }这样子的反过来成那样子的。function decodeHtmlChar($value) { $tt = $value; $tt = str_replace('','amp;',$tt); $tt = str_replace("'",''',$tt); $tt = str_replace('"','"',$tt); $tt = str_replace('<','<',$tt); $tt = str_replace('>','>',$tt); return $tt; }后来,就可以了。。你们开始还告诉我是一样的。。为什么我反的就可以???好像还是不能理解。。 喂,lzkd(浪子快刀),你什么意思嘛?要说人家笨的话就直说。。我不会介意的呀。 哦...楼主不要误会.....因为觉得楼主的风格挺熟的,刚才狂想了半天,搜索了以前的帖子,想起以前我回答过你一个帖,关于session的.只是觉得挺有意思,绝对没有别的,我保证..呵... 你要的是这个?str_replace字符串取代。语法: string str_replace(string needle, string str, string haystack);返回值: 字符串函数种类: 资料处理 内容说明 本函数将字符串 str 代入 haystack 字符串中,将所有的 needle 置换成 str。[email protected] (11-Apr-1999) 指出在 PHP 3.0.7 版,本函数有些 bug,而 [email protected] (05-Jun-1999) 补充在 PHP 3.0.8 版本函数就回复正常了。 使用范例 下例将 %body% 以 black 取代<?php$bodytag = str_replace("%body%", "black", "<body text=%body%>");echo $bodytag;?> 管理权限 做个照片网站-请问如何来设计限制照片可见性 请各位帮我看段代码 Smarty中怎么样在变量中使用变量 数据库数据调用问题 读取xml数据之后smarty的模板应该怎么写 请教:关于从数据库记录返回数据的大小? 显示数据库内容的问题 运行php出现odbc32.dll找不到的问题 如何实现一个导出文件的进度条? 如何把EXCLE表里的数据导入MYSQL数据库中呢? (一)200 高分求Red Hat 考试题答案回答中英文均可最好是中英都有!
$tt = str_replace('"','"',$tt); $str = str_replace("\", """,$str);
$tt = str_replace('"','"',$tt); $str = str_replace("\", """,$str);
-===========================
没区别吧。
$a = stripslashes($string);
$t->setvar("name",stripslashes($re["name"]));输出的name是:
Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15\" 256MB 40GB Combo WinXP Pro Notebook 但是,给了文本框,文本框却还是到"引号之前,引号之后的就没了。
<input name="name" type="text" id="name2" value="{name}" >为什么嘛??
<input type=text value = 'Sony VAIO V505 PCG-V505DC1PC 12.1" Notebook Computer'>标准的写法是
<input type=text value = "Sony VAIO V505 PCG-V505DC1PC 12.1" Notebook Computer">
function decodeHtmlChar($value)
{
$tt = $value;
$tt = str_replace('','amp;',$tt);
$tt = str_replace("'",''',$tt);
$tt = str_replace('"','"',$tt);
$tt = str_replace('<','<',$tt);
$tt = str_replace('>','>',$tt);
return $tt;
}
///////////////////////////////
echo $re["name"];
echo "<br>";
echo stripslashes($re["name"]);
echo "<br>";
echo decodeHtmlChar($re["name"]);结果
Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15\" 256MB 40GB Combo WinXP Pro Notebook
Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15" 256MB 40GB Combo WinXP Pro Notebook
Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15\" 256MB 40GB Combo WinXP Pro Notebook
可是文框内却是
Toshiba Satellite PSA60U-02201D Cel 2.8GHz 15引号怎么不会变成"????
我把<input name="name" type="text" id="name2" value="{name}" >
改成
<input name="name" type="text" id="name2" value='{name}'>
文本框内就显示出所有的来了。可是,我不想这样改。。不要改这个。而是通过name传过来的值就可以用。怎么办?
我把原来的
function decodeHtmlChar($value)
{
$tt = $value;
$tt = str_replace('amp;','',$tt);
$tt = str_replace(''',"'",$tt);
$tt = str_replace('"','"',$tt);
$tt = str_replace('<','<',$tt);
$tt = str_replace('>','>',$tt);
return $tt;
}
这样子的反过来成那样子的。
function decodeHtmlChar($value)
{
$tt = $value;
$tt = str_replace('','amp;',$tt);
$tt = str_replace("'",''',$tt);
$tt = str_replace('"','"',$tt);
$tt = str_replace('<','<',$tt);
$tt = str_replace('>','>',$tt);
return $tt;
}
后来,就可以了。。
你们开始还告诉我是一样的。。为什么我反的就可以???好像还是不能理解。。
要说人家笨的话就直说。。我不会介意的呀。
以前我回答过你一个帖,关于session的.只是觉得挺有意思,绝对没有
别的,我保证..呵...
字符串取代。语法: string str_replace(string needle, string str, string haystack);返回值: 字符串函数种类: 资料处理
内容说明
本函数将字符串 str 代入 haystack 字符串中,将所有的 needle 置换成 str。[email protected] (11-Apr-1999) 指出在 PHP 3.0.7 版,本函数有些 bug,而 [email protected] (05-Jun-1999) 补充在 PHP 3.0.8 版本函数就回复正常了。
使用范例
下例将 %body% 以 black 取代<?php
$bodytag = str_replace("%body%", "black", "<body text=%body%>");
echo $bodytag;
?>