dongpa5277 2014-08-13 18:30
浏览 28

在$ html = string中使用PHP?

I have the following code which displays currently a YouTube video via html embed code.

 <?php
if ( function_exists( 'wpmudev_ppw_html' ) ) {
$html = '<iframe width="560" height="315" src="https://www.youtube.com/embed/-uiN9z5tqhg?wmode=transparent&" frameborder="0" allowfullscreen></iframe>'; // html code to be protected (required)
$id = 1; // An optional unique id if you are using the function more than once on a single page
$description = 'video'; // Optional description of the protected content
$price = '1.50'; // Optional price for a single view. If not set, price set in the post will be applied. If that is not set either, Unit Price in the Global Settings will be used.
echo wpmudev_ppw_html( $html, $id, $description, $price );
}
?>

I would like to remove the YouTube iFrame and have it display the following code instead.

<img class="img-responsive img-thumbnail" src="<?php the_field('macro_map'); ?>" />

However, the PHP code in the $html= line causes a syntax error when done like so...

$html = '<img class="img-responsive img-thumbnail" src="<?php the_field('macro_map'); ?>" />'; 

First, is it even possible for this to work. If so, what am I doing wrong?

  • 写回答

1条回答 默认 最新

  • dpa55065 2014-08-13 18:34
    关注

    You can't have <?php ?> inside <?php ?> tags. You will need to remove the nested tags and use a . to concatenate the string and return of the function.

    $html = '<img class="img-responsive img-thumbnail" src="' . the_field('macro_map') . '" />';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用