<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/