如何在iframe中使用PHP变量?


How can I use a PHP variable inside an iframe?

我有这个问题,我试图使用我的$test变量在我的iframe内的src部分,每次我尝试失败,只有一个黑色的边框显示。

下面是我的代码:
<?php
$url = 'http://www.youtube.com/watch?v=9t5ItWlWyDg/';
    $parts = explode('=', $url);
$url2 = $parts[1];
$url3 = trim($url2,"?'/");
    echo $url3;
$youtube = 'http://www.youtube.com/v/';
$video = $url3;
$vars = '&loop=1&autoplay=1';
 $test = ($youtube . $video . $vars);
    echo $test;
?>
<br>
 <iframe width="420" height="345"
 src="<? $test ?>">
 </iframe>

必须使用echo:

  1. src="<? echo $test ?>">

  1. src="<?=$test ?>">