download - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of download.php
- <?php
- if (isset($_POST['download'])) {
- $video_url = $_POST['video_url'];
- function getVideoId($url) {
- $pattern = '/(?:youtube\.com\/(?:[^\/]+\/[^\/]+\?.*v=|[^\/]+\/(?:v\/|embed\/|watch\?.*v=)))|youtu.be\/)([a-zA-Z0-9_\-]{11})/';
- preg_match($pattern, $url, $matches);
- return $matches[1];
- }
- function constructDownloadUrl($videoId) {
- return "https://www.youtube.com/watch?v=" . $videoId;
- }
- // Validate the YouTube URL here (optional)
- // Extract the video ID from the URL
- $video_id = getVideoId($video_url);
- // Construct the download URL
- $download_url = constructDownloadUrl($video_id);
- // Redirect to the download URL
- header("Location: $download_url");
- exit();
- }
- ?>
- <!-- Continue with the rest of the HTML code -->
File Description
- download
- PHP Code
- 19 May-2023
- 833 Bytes
You can Share it:
Latest PHP Pastes