如何在PHP脚本中的变量中存储HTML代码(带有“"”,'')? [英] How to store HTML code (with " ", ' ') inside a variable in php script?

查看:79
本文介绍了如何在PHP脚本中的变量中存储HTML代码(带有“"”,'')?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


假设我有这个简单的剧本:


<?PHP


//开始标记=''

$ html_header =''

<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"

" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

''; //关闭标签=''


echo $ html_header;


?>


如果开放& '结束标签都''然后它工作正常,但如果

html脚本本身包含''那么我需要一些方法来逃避它,不是吗?


如果我有类似< HEAD>< TITLE =''PHP foo''>< / HEAD>?

Hello to everyone,

Assuming i have this simple script :

<?PHP

//Opening tag =''
$html_header=''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
''; // Closing tag =''

echo $html_header;

?>

If the opening & closing tags are both '' then it works fine, but if the
html script itself contains a '' then i need some way to escape it, no ?

How should i do it if i had something like <HEAD><TITLE=''PHP foo''></HEAD>?

推荐答案

html_header =''

<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"

" http ://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

''; //关闭标签=''


echo
html_header=''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
''; // Closing tag =''

echo


html_header;


?>


如果开放& '结束标签都''然后它工作正常,但如果

html脚本本身包含''那么我需要一些方法来逃避它,不是吗?


如果我有类似< HEAD>< TITLE =''PHP foo''>< / HEAD>?
html_header;

?>

If the opening & closing tags are both '' then it works fine, but if the
html script itself contains a '' then i need some way to escape it, no ?

How should i do it if i had something like <HEAD><TITLE=''PHP foo''></HEAD>?


*,我应该怎么做? ** Maxim Vexler写道/escribió(周四,2004年11月11日11:35:46 +0200):
*** Maxim Vexler wrote/escribió (Thu, 11 Nov 2004 11:35:46 +0200):
如果开放& '结束标签都''然后它工作正常,但如果
html脚本本身包含''那么我需要一些方法来逃避它,不是吗?
If the opening & closing tags are both '' then it works fine, but if the
html script itself contains a '' then i need some way to escape it, no ?




\''
http://es.php.net/manual/en/language.types.string.php


-

- - álvaroG。Vicario - 西班牙布尔戈斯

- 感谢您不要通过电子邮件将您的问题发送给我

-



\''

http://es.php.net/manual/en/language.types.string.php

--
-- álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--

这篇关于如何在PHP脚本中的变量中存储HTML代码(带有“&quot;”,'')?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆