正确的语法以在iframe中回显变量 [英] correct syntax to echo variable inside iframe

查看:78
本文介绍了正确的语法以在iframe中回显变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I know i am missing something simple. I just want to display this iframe if $video-code exists. Can anyone see what is wrong with this? working in wordpress. error is on the echo line. i've also tried adding .'$video-code'. into the url.

它可以正确显示iframe,但变量在url中显示为文本.如果我在没有If语句的情况下在页面的其他位置调用变量,它将正确显示.

it is displaying the iframe correctly, but the variable is displaying as text in the url. if i call the variable elsewhere in the page without the If statement, it displays correctly.

感谢您的帮助!

<?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连接起来,就像这样:

You can concatenate your $key, like so:

echo '<iframe id="player" width="560" height="315" frameborder="2" 
src="http://www.youtube.com/embed/' . $key . '" ></iframe>';

这篇关于正确的语法以在iframe中回显变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆