我在一个单独的php文件中的PHP echo命令上有一些HTML内容。代码如下所示..
<?php
echo "
<div id="footer">
<div id="footer-contact">
<p><strong>Gardencrafts Heswall Limited</strong> <br> The Nurseries, Lower Thingwall Lane, Thingwall, <br> Wirral CH61 1AZ</p>
<p><strong>Telephone :</strong> 0151 648 5840</p>
<p><strong>Fax :</strong> 0151 648 5840</p>
<p><strong>Email :</strong> gardencrafts1@gmail.com</p>
</div>
<div id="footer-icons">
<div id="social-tab">
<div id="twitter"><a href='https://twitter.com/GardencraftsUk' class='twitter-follow-button' data-show-count="false">Follow @GardencraftsUk</a></div>
<div class="fb-like" data-href='https://www.facebook.com/pages/Gardencrafts/200615766704712?fref=ts' data-send="false" data-layout="button_count" data-width="200" data-show-faces="false" data-font="trebuchet ms"></div>
</div>
<div id="awards">
<img src="images/f1.jpg">
<img src="images/f2.jpg">
<img src="images/f3.jpg">
</div>
<div id="copy">
<p>Copyright © 2011 Gardencrafts.</p>
</div>
</div>
</div>
";
?>
我将其包含在带有以下代码的php页面中。
<?php include("../script/footer.php"); ?>
scrpit位于网站根目录中名为scrpit的文件夹中..但是当我包含此内容时,内容未显示!谁能帮帮我吗!
谢谢。
答案 0 :(得分:4)
您的文件中存在语法错误。添加\
以转义引号或将其更改为单引号:
<?php
echo "
<div id=\"footer\">
<div id=\"footer-contact\">
<p><strong>Gardencrafts Heswall Limited</strong> <br> The Nurseries, Lower Thingwall Lane, Thingwall, <br> Wirral CH61 1AZ</p>
<p><strong>Telephone :</strong> 0151 648 5840</p>
<p><strong>Fax :</strong> 0151 648 5840</p>
<p><strong>Email :</strong> gardencrafts1@gmail.com</p>
</div>
<div id=\"footer-icons\">
<div id=\"social-tab\">
<div id=\"twitter\"><a href='https://twitter.com/GardencraftsUk' class='twitter-follow-button' data-show-count=\"false\">Follow @GardencraftsUk</a></div>
<div class=\"fb-like\" data-href='https://www.facebook.com/pages/Gardencrafts/200615766704712?fref=ts' data-send=\"false\" data-layout=\"button_count\" data-width=\"200\" data-show-faces=\"false\" data-font=\"trebuchet ms\"></div>
</div>
<div id=\"awards\">
<img src=\"images/f1.jpg\">
<img src=\"images/f2.jpg\">
<img src=\"images/f3.jpg\">
</div>
<div id=\"copy\">
<p>Copyright © 2011 Gardencrafts.</p>
</div>
</div>
</div>
";
?>
答案 1 :(得分:0)
为什么要回复这样的HTML块?没有必要这样做。 你的路径对吗? (你描述的将包括('script / footer.php');)
答案 2 :(得分:0)
<?php include("script/footer.php"); ?>
像这样包含你的页脚文件。认为它会对你有所帮助。
答案 3 :(得分:0)
首先在echo之后,最后使用单引号而不是双引号,它会起作用,如下所示:
<?php
echo '
<div id="footer">
<div id="footer-contact">
<p><strong>Gardencrafts Heswall Limited</strong> <br> The Nurseries, Lower Thingwall Lane, Thingwall, <br> Wirral CH61 1AZ</p>
<p><strong>Telephone :</strong> 0151 648 5840</p>
<p><strong>Fax :</strong> 0151 648 5840</p>
<p><strong>Email :</strong> gardencrafts1@gmail.com</p>
</div>
<div id="footer-icons">
<div id="social-tab">
<div id="twitter"><a href="https://twitter.com/GardencraftsUk" class="twitter-follow-button" data-show-count="false">Follow @GardencraftsUk</a></div>
<div class="fb-like" data-href="https://www.facebook.com/pages/Gardencrafts/200615766704712?fref=ts" data-send="false" data-layout="button_count" data-width="200" data-show-faces="false" data-font="trebuchet ms"></div>
</div>
<div id="awards">
<img src="images/f1.jpg">
<img src="images/f2.jpg">
<img src="images/f3.jpg">
</div>
<div id="copy">
<p>Copyright © 2011 Gardencrafts.</p>
</div>
</div>
</div>
';
?>
在里面,你需要只有双引号或者像单引号一样转义。'
LOL。或者只是输出没有回声的html代码,如下所示:
<div id="footer">
<div id="footer-contact">
<p><strong>Gardencrafts Heswall Limited</strong> <br> The Nurseries, Lower Thingwall Lane, Thingwall, <br> Wirral CH61 1AZ</p>
<p><strong>Telephone :</strong> 0151 648 5840</p>
<p><strong>Fax :</strong> 0151 648 5840</p>
<p><strong>Email :</strong> gardencrafts1@gmail.com</p>
</div>
<div id="footer-icons">
<div id="social-tab">
<div id="twitter"><a href="https://twitter.com/GardencraftsUk" class="twitter-follow-button" data-show-count="false">Follow @GardencraftsUk</a></div>
<div class="fb-like" data-href="https://www.facebook.com/pages/Gardencrafts/200615766704712?fref=ts" data-send="false" data-layout="button_count" data-width="200" data-show-faces="false" data-font="trebuchet ms"></div>
</div>
<div id="awards">
<img src="images/f1.jpg">
<img src="images/f2.jpg">
<img src="images/f3.jpg">
</div>
<div id="copy">
<p>Copyright © 2011 Gardencrafts.</p>
</div>
</div>
</div>
答案 4 :(得分:0)
你为什么使用php标签和echo?这样做,只有该页面中的内容(html)。如果你想在这里使用任何php内容,只需添加<?php echo $content; ?>
即可。
<div id="footer">
<div id="footer-contact">
<p><strong>Gardencrafts Heswall Limited</strong> <br> The Nurseries, Lower Thingwall Lane, Thingwall, <br> Wirral CH61 1AZ</p>
<p><strong>Telephone :</strong> 0151 648 5840</p>
<p><strong>Fax :</strong> 0151 648 5840</p>
<p><strong>Email :</strong> gardencrafts1@gmail.com</p>
</div>
<div id="footer-icons">
<div id="social-tab">
<div id="twitter"><a href='https://twitter.com/GardencraftsUk' class='twitter-follow-button' data-show-count="false">Follow @GardencraftsUk</a></div>
<div class="fb-like" data-href='https://www.facebook.com/pages/Gardencrafts/200615766704712?fref=ts' data-send="false" data-layout="button_count" data-width="200" data-show-faces="false" data-font="trebuchet ms"></div>
</div>
<div id="awards">
<img src="images/f1.jpg">
<img src="images/f2.jpg">
<img src="images/f3.jpg">
</div>
<div id="copy">
<p>Copyright © 2011 Gardencrafts.</p>
</div>
</div>
</div>
答案 5 :(得分:0)
尝试在div中使用单引号而不是双引号,就像
一样<?php
echo "<div id='footer'></div>";
&GT;
这也可能会有所帮助。