How to Embed YouTube Videos on a PHP-Based Website?

Linda Hamilton
Release: 2024-10-18 16:36:03
Original
795 people have browsed it

How to Embed YouTube Videos on a PHP-Based Website?

Embedding YouTube Videos in PHP

Want to display YouTube videos on your PHP-based website? Here's how it's done:

Step 1: Obtain the Unique Video Code

Request users to provide the unique 11-character code found in the YouTube video URL. For instance, for the URL http://www.youtube.com/watch?v=Ahg6qcgoay4, the code is Ahg6qcgoay4.

Step 2: Store the Code in a Database

Record the obtained code in a database for future use.

Step 3: Embed the Video

Use the following HTML code to embed the video anywhere on your webpage:

<code class="html"><object width="425" height="350" data="http://www.youtube.com/v/{VIDEO_CODE}" type="application/x-shockwave-flash">
  <param name="src" value="http://www.youtube.com/v/{VIDEO_CODE}" />
</object></code>
Copy after login

Example

For the video with the code Ahg6qcgoay4, the embed code would be:

<code class="html"><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></code>
Copy after login

The above is the detailed content of How to Embed YouTube Videos on a PHP-Based Website?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template