Class PHP>;无法按函数嵌入youtube视频
我不知道我的嵌入脚本有什么问题,按照我的逻辑,它应该正确地将视频嵌入到帧中,但它加载的是www.youtube.com的帧视图,而不是我的视频 单个目录中有2个文件: ClassMedia.php:Class PHP>;无法按函数嵌入youtube视频,class,function,youtube,embed,media,Class,Function,Youtube,Embed,Media,我不知道我的嵌入脚本有什么问题,按照我的逻辑,它应该正确地将视频嵌入到帧中,但它加载的是www.youtube.com的帧视图,而不是我的视频 单个目录中有2个文件: ClassMedia.php: <?php class Media { public function embedYT($code){ echo "<iframe width='560' height='349' src='http://www.youtube.com/embed/".$co
<?php
class Media {
public function embedYT($code){
echo "<iframe width='560' height='349' src='http://www.youtube.com/embed/".$code." frameborder='0' allowfullscreen></iframe>";
}}
演示
您在src>之后缺少一个引号http://www.youtube.com/embed/“$code.”
,您需要:
echo "<iframe width='560' height='349' src='http://www.youtube.com/embed/".$code."' frameborder='0' allowfullscreen></iframe>";
echo”“;
注意添加的单引号
YouTube最终发现一个错误的URL(
http://www.youtube.com/embed/$code frameborder=
其中$code
是真正的代码)并将主页交给您,而不是您认为需要的内容。非常感谢,就这样!
echo "<iframe width='560' height='349' src='http://www.youtube.com/embed/".$code."' frameborder='0' allowfullscreen></iframe>";