我知道我缺少一些简单的东西。如果$ video-code存在,我只想显示此iframe。谁能看到这有什么问题吗?在WordPress中工作。错误在回声线上。我也尝试添加。'$ video-code'。进入网址。
它正确显示了iframe,但变量在网址中显示为文本。如果我在没有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>';
}?>
最佳答案
您可以连接$key
,如下所示:
echo '<iframe id="player" width="560" height="315" frameborder="2"
src="http://www.youtube.com/embed/' . $key . '" ></iframe>';
关于php - 正确的语法以在iframe中回显变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17824573/