我目前正在为我的学校开发一个Webproject,它是用HTML,PHP和SQL数据库构建的动态内容。到目前为止,一切都很好,但我已经达到了一个点,我必须回应一些包含许多字符的内容,例如''和""这几乎不可能将PHP echo与那些起始标签一起使用('''""")。还有其他方法可以启动PHP回声吗?
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> ';
答案 0 :(得分:1)
另一种解决方案是老去学校并使用10年前使用过的PHP:
<?php
if ($rows[$number]['kulturschule'] == 1) {
?>
<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>
<?php } ?>
答案 1 :(得分:0)
您可以使用以下方法来转义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\"}]";