3v4l.org

run code in 300+ PHP versions simultaneously
<?php /***************************************************************** Created : 2014/03/25 Author : Mr. Khwanchai Kaewyos (LookHin) E-mail : khwanchai@gmail.com Website : www.LookHin.com Blog : www.unzeen.com Copyright (C) 2014, www.LookHin.com all rights reserved. *****************************************************************/ set_time_limit(0); $strMp4Folder = "./mp4/"; $strYoutubeDownloadUrl = " http://youtu.be/z-FNiOs_748 https://www.youtube.com/watch?v=gwKBOnMmpvU https://www.youtube.com/watch?v=dh7GMmRsQvA "; $arrYoutubeId = explode("\n", trim($strYoutubeDownloadUrl)); foreach ($arrYoutubeId as $key => $value) { // Get Youtube ID preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $value, $matches); $strYoutubeId = trim($matches[1]); print "Download => {$strYoutubeId}\n"; // Get Title Name $json = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$strYoutubeId}?v=2&alt=json"),true); $strTitleName = iconv("UTF-8", "TIS-620", preg_replace("/[\"'\/:|\\\?\$\*%\-\+ ]/", "-", $json['entry']['title']['$t'])); // Get Mp4 Link $strMp4LinkTmp = ""; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,1); curl_setopt($ch, CURLOPT_URL,"http://www.youtube.com/watch?v={$strYoutubeId}"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0"); curl_setopt($ch, CURLOPT_REFERER, "http://www.youtube.com/watch?v={$strYoutubeId}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch); //print $result; preg_match_all("|url_encoded_fmt_stream_map\"\: \"(.*)\"|U",$result,$out, PREG_PATTERN_ORDER); $arrUrl = explode(',',$out[1][0]); foreach($arrUrl as $url){ if(substr_count(urldecode($url), "type=video/mp4") > 0 && substr_count(urldecode($url), "quality=medium") > 0){ $arrTmp = explode("\\u0026",urldecode($url)); $strUrl = ""; $strSig = ""; foreach($arrTmp as $strTmp){ if(substr_count(urldecode($strTmp), "url=") > 0){ $tmp = explode('url=',$strTmp); $strUrl = $tmp[1]; } if(substr_count(urldecode($strTmp), "sig=") > 0){ $tmp = explode('sig=',$strTmp); $strSig = $tmp[1]; } } $strMp4LinkTmp = $strUrl."&signature=".$strSig; //print $strMp4LinkTmp; } } // Download if($strMp4LinkTmp != ""){ //print $strMp4LinkTmp; copy($strMp4LinkTmp,"{$strMp4Folder}{$strTitleName}.mp4"); } } print "\n\nDownload Complete\n\n"; ?>
Output for 8.3.0 - 8.3.4, 8.3.6
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for gdata.youtube.com failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): Failed to open stream: php_network_getaddresses: getaddrinfo for gdata.youtube.com failed: System error in /in/GsSNc on line 25 Warning: Trying to access array offset on null in /in/GsSNc on line 26 Warning: Trying to access array offset on null in /in/GsSNc on line 26 Warning: Trying to access array offset on null in /in/GsSNc on line 26 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/GsSNc on line 26 Warning: iconv(): Wrong encoding, conversion from "UTF-8" to "TIS-620" is not allowed in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for gdata.youtube.com failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): Failed to open stream: php_network_getaddresses: getaddrinfo for gdata.youtube.com failed: System error in /in/GsSNc on line 25 Warning: Trying to access array offset on null in /in/GsSNc on line 26 Warning: Trying to access array offset on null in /in/GsSNc on line 26 Warning: Trying to access array offset on null in /in/GsSNc on line 26 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/GsSNc on line 26 Warning: iconv(): Wrong encoding, conversion from "UTF-8" to "TIS-620" is not allowed in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for gdata.youtube.com failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): Failed to open stream: php_network_getaddresses: getaddrinfo for gdata.youtube.com failed: System error in /in/GsSNc on line 25 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/GsSNc on line 26 Warning: iconv(): Wrong encoding, conversion from "UTF-8" to "TIS-620" is not allowed in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 8.0.14 - 8.0.30
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): Failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: iconv(): Wrong encoding, conversion from "UTF-8" to "TIS-620" is not allowed in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 8.0.13
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): Failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Fatal error: Uncaught Error: Call to undefined function iconv() in /in/GsSNc:26 Stack trace: #0 {main} thrown in /in/GsSNc on line 26
Process exited with code 255.
Output for 8.0.0 - 8.0.12
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): Failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Warning: Trying to access array offset on value of type null in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Fatal error: Uncaught Error: Call to undefined function iconv() in /in/GsSNc:26 Stack trace: #0 {main} thrown in /in/GsSNc on line 26
Process exited with code 255.
Output for 7.4.26 - 7.4.32
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/GsSNc on line 25 Notice: Trying to access array offset on value of type null in /in/GsSNc on line 26 Notice: Trying to access array offset on value of type null in /in/GsSNc on line 26 Notice: Trying to access array offset on value of type null in /in/GsSNc on line 26 Notice: iconv(): Wrong charset, conversion from `UTF-8' to `TIS-620' is not allowed in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 7.4.0 - 7.4.25
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Notice: Trying to access array offset on value of type null in /in/GsSNc on line 26 Notice: Trying to access array offset on value of type null in /in/GsSNc on line 26 Notice: Trying to access array offset on value of type null in /in/GsSNc on line 26 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/GsSNc:29 Stack trace: #0 {main} thrown in /in/GsSNc on line 29
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Download => z-FNiOs_748 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/z-FNiOs_748?v=2&alt=json): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/GsSNc on line 25 Fatal error: Call to undefined function curl_init() in /in/GsSNc on line 29
Process exited with code 255.

preferences:
253.95 ms | 402 KiB | 335 Q