php - 使用 CSS 和 file_get_contents 时根本不回显文本

标签 php css echo title

<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 echo,我不知道为什么?我希望视频显示在顶部并使用 $str 作为视频的标题。

最佳答案

您的视频容器和主体高度相等,因此该 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>

关于php - 使用 CSS 和 file_get_contents 时根本不回显文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16563781/

相关文章:

Express 应用程序中的 CSS 字体面部路径不起作用

java - 为什么 php 页面在 LogCat 中不显示相同的内容?

bash - bash 中的全局重命名

使用ajax调用PHPExcel下载

PHP、MySQL if、else 条件不起作用

html - 如何在 flex 中为每个 div 分配均匀的空间

php - 如何将谷歌自动完成整个 div 移动到另一个 div

php - ECHO 没有错误但不显示来自 MYSQL 的数据

php - 相信 BCC 不会泄露其他人的地址是个好主意吗?

php - while循环没有输出正确的结果