duandian4501 2017-08-07 13:57
浏览 72
已采纳

HTML中的echo php变量(wordpress)

I have created a custom wordpress post type everything works but my client asked me to insert a function that doenst show the button if the link field is empty that is also working but when I want to display the tekst or link the part where the php is inserted just doesnt shows up what am I doing wrong

I am able to get the data on other parts of this php file but not in this part of the page

<?php 
   $linktitle = $day_aray=get_field("under_shoe_button_title");
   $linkexist = get_field("under_shoe_button_link");    
   echo($linktitle);
   if (empty($linkexist)) {    
       echo '<html> <p></p></html>' ;           
   }    
   else {       
       echo '<html>
       <a href="google.nl"  class="button primary is-bevel box-shadow-3 box-shadow-4-hover expand" style="border-radius:5px;" 
       </html> <?php echo($linktitle); ?> <html><span></span>
       <i class="icon-shopping-cart"></i></a>
       </html>';    
   }
?>
  • 写回答

2条回答 默认 最新

  • duan0513 2017-08-07 14:06
    关注

    If you would look carefully, you would notice, that you are echoing a string where, inside the string, you are trying to echo again. Even with little programming knowledge, you should understand, that it is not logical to do that.

    The same goes for php opening <?php tag. You opened the tag at start of the page and later on, inside a string, you are trying to open it again. This does not work.

    Instead, close the string (or escape it) and then add the echo option.

       echo '<html>
       <a href="google.nl"  class="button primary is-bevel box-shadow-3 box-shadow-4-hover expand" style="border-radius:5px;" 
       </html>';
       echo($linktitle);
       echo '<html><span></span>
       <i class="icon-shopping-cart"></i></a>
       </html>'; 
    

    And please, read the comments to you question and learn basic HTML

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料