0

我知道我缺少一些简单的东西。如果 $video-code 存在,我只想显示这个 iframe。谁能看到这有什么问题?在wordpress中工作。错误在回声线上。我也试过添加 .'$video-code'。进入网址。

它正确显示 iframe,但变量在 url 中显示为文本。如果我在没有 If 语句的情况下在页面的其他地方调用变量,它会正确显示。

谢谢你的帮助!

<?php
$key = 'video-code';
$themeta = get_post_meta($post->ID, $key, TRUE);
if($themeta != '') {
echo '<iframe id="player" width="560" height="315" frameborder="2"     src="http://www.youtube.com/embed/$video-code" ></iframe>';
}?>
4

1 回答 1

1

您可以连接您的$key,如下所示:

echo '<iframe id="player" width="560" height="315" frameborder="2" 
src="http://www.youtube.com/embed/' . $key . '" ></iframe>';
于 2013-07-24T03:14:29.267 回答