日期:2014-05-17  浏览次数:20525 次

php字符串的简单问题
现在有很长的一串html代码,比如:

<!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 7]>
<html id="ie7" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 8]>
<html id="ie8" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
<html dir="ltr" lang="zh-CN">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
。。。。。。。


我想把它赋值给一个php变量,该怎么写?

我写:

<?
$a = 。。。(上述的html代码)
?>


出错,求解。


不要说把这段html转义,因为很长,不太可能一个一个字符转义

------解决方案--------------------
$a =<<< TXT
<!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 7]>
<html id="ie7" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 8]>
<html id="ie8" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
<html dir="ltr" lang="zh-CN">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
......
TXT; //这里必须顶格写