3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace ZarkielMedia; class Youtube{ private $videoMap = array( "13" => array("3GP", "Low Quality - 176x144"), "17" => array("3GP", "Medium Quality - 176x144"), "36" => array("3GP", "High Quality - 320x240"), "5" => array("FLV", "Low Quality - 400x226"), "6" => array("FLV", "Medium Quality - 640x360"), "34" => array("FLV", "Medium Quality - 640x360"), "35" => array("FLV", "High Quality - 854x480"), "43" => array("WEBM", "Low Quality - 640x360"), "44" => array("WEBM", "Medium Quality - 854x480"), "45" => array("WEBM", "High Quality - 1280x720"), "18" => array("MP4", "Medium Quality - 480x360"), "22" => array("MP4", "High Quality - 1280x720"), "37" => array("MP4", "High Quality - 1920x1080"), "38" => array("MP4", "High Quality - 4096x230") ); private $videoPageUrl = 'http://www.youtube.com/watch?v='; protected function getPageContent($id){ $page = $this->videoPageUrl.$id; $content = file_get_contents($page); return $content; } function getDownloadLinks($id){ $content = $this->getPageContent($id); $videos = array('MP4' => array(), 'FLV' => array(), '3GP' => array(), 'WEBM' => array()); if(preg_match('/"url_encoded_fmt_stream_map": "(.*)"/iUm', $content, $r)){ $data = $r[1]; $data = explode(',', $data); foreach($data As $cdata){ $cdata = str_replace('u0026', '&', $cdata); $cdata = explode('&', $cdata); foreach($cdata As $xdata){ if(preg_match('/^sig/', $xdata)){ $sig = substr($xdata, 4); } if(preg_match('/^url/', $xdata)){ $url = substr($xdata, 4); } if(preg_match('/^itag/', $xdata)){ $type = substr($xdata, 5); } } $url = urldecode($url).'&signature='.$sig; $videos[$this->videoMap[$type][0]][$this->videoMap[$type][1]] = $url; } } return $videos; } } $youtube = new Zarkiel\Media\Youtube(); $download_links = $youtube->getDownloadLinks('q_gfD3nvh-8'); print_r($download_links);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Class "ZarkielMedia\Zarkiel\Media\Youtube" not found in /in/84JUr:68 Stack trace: #0 {main} thrown in /in/84JUr on line 68
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 Fatal error: Uncaught Error: Class "ZarkielMedia\Zarkiel\Media\Youtube" not found in /in/84JUr:68 Stack trace: #0 {main} thrown in /in/84JUr on line 68
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'ZarkielMedia\Zarkiel\Media\Youtube' not found in /in/84JUr:68 Stack trace: #0 {main} thrown in /in/84JUr on line 68
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.40
Fatal error: Class 'ZarkielMedia\Zarkiel\Media\Youtube' not found in /in/84JUr on line 68
Process exited with code 255.

preferences:
211.47 ms | 402 KiB | 245 Q