0
<html>
<?php
$url = "http://www.youtube.com/embed/FTGNAupPqpU";
$str = "title of video here";
$css = <<<EOT
<style type="text/css">
 body
   {
   background: #eeeeee;
   width:560px; 
   height:315px;
   }
</style>
EOT;
$data = file_get_contents($url);
$data = str_replace('</body>', $css.'</body>', $data);
echo '<div style="overflow:scroll;">'.$data.'</div>';
echo $str
?>
</html>

什么时候$url存储了一个变量(主要是一个 YouTube 视频),它根本不回显$str,但是$url什么时候没有$str回显,我不知道为什么?我希望视频出现在顶部并$str用作视频的标题。

4

2 回答 2

4

您的视频容器和正文高度相等,因此该 div 之后的所有内容都被隐藏了看看这是否有效:

<html>
<?php
$url = "http://www.youtube.com/embed/FTGNAupPqpU";
$str = "title of video here";
$css = <<<EOT
<style type="text/css">
 body
   {
   background: #eeeeee;
   width:560px; 
   height:315px;
   color:#000;
   }
</style>
EOT;
$data = file_get_contents($url);
$data = str_replace('</body>', $css.'</body>', $data);
echo '<div style="overflow:scroll; height:300px;">'.$data.'</div>';
echo $str;
?>
</html>
于 2013-05-15T11:53:46.313 回答
0

试试这个..您需要控制显示数据的 div 的高度和宽度

<html>
<?php
$url = "http://www.youtube.com/embed/FTGNAupPqpU";
$str = "title of video here";
$css = <<<EOT
<style type="text/css">
 body
 {
  background: #fff;
    width:560px; 
  height:315px;
  }
</style>
EOT;
$data = file_get_contents($url);
echo '<div style="overflow:scroll; height:500px;width:500px">'.$data.'</div>';
echo $str
?>
</html>

phpfiddle

于 2013-05-15T11:57:39.070 回答