dongpinyao2203 2014-02-14 14:05
浏览 59
已采纳

如何在echo HTML内容中包含PHP中的完整URL [关闭]

I'm trying to load content to an HTML page using PHP files. I've done this successfully using the echo statement. The issue I am running into now is using full URL's that sit within the HTML within the echo statement - whenever the PHP file sees two backslashes // it starts to comment out the code for that line, then seems to ignore the rest of the HTML as part of the echo

How can I use this PHP file to successfully load HTML content that contains URLs? See below for a code reference.

<?php

echo "
<div class="footer">


<!--   *****   Social media icons   *****   -->
<div class="socialIcons">

    <ul>
        <li><a href="http://www.twitter.com/" title="Twitter"><img src="./design/twitter.jpg" alt="My Twitter" /></a></li>
        <li><a href="http://www.pinterest.com/" title="Pinterest"><img src="./design/pinterest.jpg" alt="My Pinterest" /></a></li>
        <li><a href="http://www.linkedin.com/" title="LinkedIn"><img src="./design/linkedin.jpg" alt="Me on LinkedIn" /></a></li>
    </ul>
</div>
<ul>
<li><a href="javascript:void(0)">Contact</a></li>
<li><a href="javascript:void(0)">About</a></li>
<li><a href="javascript:void(0)">Privacy</a></li>
</ul>

</div>
"
?>
  • 写回答

2条回答 默认 最新

  • doo58088 2014-02-14 14:08
    关注

    Comment: That's because you are using " to start the echo and then using " again to assign the parameters to the elements.

    <?php
    
    echo '
        <div class="footer">
    
            <!--   *****   Social media icons   *****   -->
            <div class="socialIcons">
    
                <ul>
                    <li>
                        <a href="http://www.twitter.com/" title="Twitter">
                            <img src="./design/twitter.jpg" alt="My Twitter" />
                        </a>
                    </li>
                    <li>
                        <a href="http://www.pinterest.com/" title="Pinterest">
                            <img src="./design/pinterest.jpg" alt="My Pinterest" />
                        </a>
                    </li>
                    <li>
                        <a href="http://www.linkedin.com/" title="LinkedIn">
                            <img src="./design/linkedin.jpg" alt="Me on LinkedIn" />
                        </a>
                    </li>
                </ul>
            </div>
    
            <ul>
                <li>
                    <a href="javascript:void(0)">Contact</a>
                </li>
                <li>
                    <a href="javascript:void(0)">About</a>
                </li>
                <li>
                    <a href="javascript:void(0)">Privacy</a>
                </li>
            </ul>
    
        </div>
    ';
    ?>
    

    Change the echo initial and final " to '. Problem solved.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址