我目前正在为我的学校开发一个 Web 项目,该项目是使用 HTML、PHP 和 SQL 数据库构建的,用于动态内容。到目前为止,一切都很好,但我已经达到了这样一个地步,我必须回显一些包含许多字符的东西,比如 '' 和 ""这几乎使得无法使用 PHP echo 与那些起始标签('' 和 "").还有其他方法可以启动 PHP echo 吗?
if ($rows[$number]['kulturschule'] == 1) {
echo '<div class="tp-caption tp-resizeme hover-scale"
data-x="center"
data-y="center"
data-voffset="[290, 290, 250, 210]"
data-hoffset="0"
data-frames='[{"delay":1000,"speed":2000,"frame":"0","from":"sX:0.9;sY:0.9;opacity:0;fb:20px;","to":"o:1;fb:0;","ease":"Power3.easeInOut"},{"delay":"wait","speed":500,"frame":"999","to":"sX:0.9;sY:0.9;opacity:0;fb:20px;","ease":"Power3.easeInOut"}]'
style="z-index: 20; max-width: auto; max-height: auto; white-space: nowrap;"><a href="http://www.km-bw.de/Kulturschule"><img src="img/logo/kulturschule.jpg"></a> ';
最佳答案
这是使用 HEREDOC 的完美情况:
// put all the html in a variable:
$html = <<<EOT
<div class="tp-caption tp-resizeme hover-scale"
data-x="center"
data-y="center"
data-voffset="[290, 290, 250, 210]"
data-hoffset="0"
data-frames='[{"delay":1000,"speed":2000,"frame":"0","from":"sX:0.9;sY:0.9;opacity:0;fb:20px;","to":"o:1;fb:0;","ease":"Power3.easeInOut"},{"delay":"wait","speed":500,"frame":"999","to":"sX:0.9;sY:0.9;opacity:0;fb:20px;","ease":"Power3.easeInOut"}]'
style="z-index: 20; max-width: auto; max-height: auto; white-space: nowrap;"><a href="http://www.km-bw.de/Kulturschule"><img src="img/logo/kulturschule.jpg"></a>
EOT;
// note, that EOT; has to be at the very start of the line.
// then:
echo $html;
关于php - 在不使用 ' ' 或 ""的情况下初始化 PHP echo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48988917/