Want to display YouTube videos on your PHP-based website? Here's how it's done:
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.
Record the obtained code in a database for future use.
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>
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>
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!