如何在PHP中嵌入YouTube视频? [英] How to embed YouTube videos in PHP?

查看:140
本文介绍了如何在PHP中嵌入YouTube视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以给我一个想法,如果我们只有URL或嵌入代码,我们如何显示或嵌入YouTube视频?

解决方案

您必须要求用户存储youtube视频中的11个字符代码。



例如 http://www.youtube.com/watch?v=Ahg6qcgoay4



十一个字符代码是:Ahg6qcgoay4



然后,您将此代码放入数据库中。然后,无论您希望将YouTube视频放在您的网页中的哪个位置,都可以从数据库中加载该字符并输入以下代码: - $ /

例如。对于Ahg6qcgoay4,它将是:

 < object width =425height =350data =http:// www.youtube.com/v/Ahg6qcgoay4type =application / x-shockwave-flash>< param name =srcvalue =http://www.youtube.com/v/Ahg6qcgoay4/> ;< /对象> 


Can anyone give me an idea how can we show or embed a YouTube video if we just have the URL or the Embed code?

解决方案

You have to ask users to store the 11 character code from the youtube video.

For e.g. http://www.youtube.com/watch?v=Ahg6qcgoay4

The eleven character code is : Ahg6qcgoay4

You then take this code and place it in your database. Then wherever you want to place the youtube video in your page, load the character from the database and put the following code:-

e.g. for Ahg6qcgoay4 it will be :

<object width="425" height="350" data="http://www.youtube.com/v/Ahg6qcgoay4" type="application/x-shockwave-flash"><param name="src" value="http://www.youtube.com/v/Ahg6qcgoay4" /></object>

这篇关于如何在PHP中嵌入YouTube视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆