dongyun3805 2016-03-27 19:57 采纳率: 0%
浏览 4

Php包括(')和(“)[重复]

I'm using Php include to minimalize my HTMl code, a somewhat issue I have when doing so is when I include something in PHP with multiple quotations (" and '), for example:

<?php echo '
    <div class="section" id="left">
     <div class="leftwrappercontent">
       <div class="brandname">
        <hr>
         <p class="leftname">  Aldos Snow</p>
         <hr>
         <p class="chinese"><img id="namecolor" src="img/name/XDDlvVU.png" alt="My's Chinese Name"><!--張文誠--></p><!--http://en.justfont.com/fontdetail/152-->
         <hr class="lasthr">
       </div>
       <div class="socialstuff">
         <a href="" target="_blank"><i class="fa fa-twitter" id="tweet"></i></a>
         <a href="" target="_blank"><i class="fa fa-instagram" id="insta"></i></a>
         <a href="" target="_blank"><i class="fa fa-pinterest" id="pint"></i></a>       
       </div>
     </div>
    </div>
    '
    ?>

If you paste this into a PHP file, you will see that you have to change all the quotations in the middle to be the same so it doesn't conflict with the outer PHP quotations, is there a way around this or do I have to manually change all of them?

</div>
  • 写回答

1条回答 默认 最新

  • doubaolan2842 2016-03-27 20:03
    关注

    I recommend not echoing HTML, it will avoid problems like you describe - and help with syntax highlighting in your editor

    <?php
    // some php stuff here
    $leftname = 'Aldos Snow';
    ?>
    <div class="section" id="left">
      <div class="leftwrappercontent">
        <div class="brandname">
          <hr>
          <p class="leftname"><?= $leftname ?></p>
          <hr>
          <p class="chinese"><img id="namecolor" src="img/name/XDDlvVU.png" alt="My's Chinese Name"><!--張文誠--></p><!--http://en.justfont.com/fontdetail/152-->
           <hr class="lasthr">
         </div>
         <div class="socialstuff">
           <a href="" target="_blank"><i class="fa fa-twitter" id="tweet"></i></a>
           <a href="" target="_blank"><i class="fa fa-instagram" id="insta"></i></a>
           <a href="" target="_blank"><i class="fa fa-pinterest" id="pint"></i></a>       
         </div>
       </div>
      </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器