3v4l.org

run code in 300+ PHP versions simultaneously
<?php function validId($cid, $vid, $type) { switch($type) { case 'channel': // live stream $response = drupal_http_request('http://x'.$cid.'x.' . MEDIA_LIVESTREAM_REST_CHANNEL_API . 'info.json'); //from Livestream submodule getChannelProperties break; case 'video': // on-demand video clip $response = drupal_http_request('http://x'.$cid.'x.' . MEDIA_LIVESTREAM_REST_CHANNEL_API . 'clipdetails.json?id='.$vid); //from getVideoProperties break; } return ($response->code == 200); } function parse($embedCode) { $embedCode = trim($embedCode); $match = FALSE; // The Livestream short code. if (!$match && preg_match('@livestre\.am/([0-9a-zA-Z\-]+)$@i', $embedCode, $matches)) { $headers = media_livestream_get_short_code($matches[0]); $embedCode = $headers['url']; } // This one checks for a channel. // E.g. livestream.com/channelname. if (!$match && preg_match('@livestream\.com/([0-9a-zA-Z\-]+)$@i', $embedCode, $matches)) { $match = TRUE; $type = 'channel'; $channel_id = $matches[1]; $video_id = $matches[1]; } // This one checks for a channel iframe. // E.g. livestream.com/embed/channelname. (And no clip (id) set). elseif (!$match && preg_match('@livestream\.com/embed/([0-9a-zA-Z\-]+)?((?!clip|clipId).)*$@i', $embedCode, $matches)) { $match = TRUE; $type = 'channel'; $channel_id = $matches[1]; $video_id = $matches[1]; } // This one works for 'video' and 'share' on a new style link. // E.g. livestream.com/channelname/video(or)share/clip(id). elseif (!$match && preg_match('@livestream\.com/([0-9a-zA-Z\-]+).*/(video|share).*((clipId|clip)=([^\&\'" ]+))@i', $embedCode, $matches)) { $match = TRUE; $type = 'video'; $channel_id = $matches[1]; $video_id = $matches[5]; } // This one matches the new iframe embed for videos. // E.g. livestream.com/embed/channelname/clip(id). elseif (!$match && preg_match('@livestream\.com/(embed)/([0-9a-zA-Z\-]+).*((clipId|clip)=([^\&\'" ]+))@i', $embedCode, $matches)) { $match = TRUE; $type = 'video'; $channel_id = $matches[2]; $video_id = $matches[5]; } // This one also checks for a channel, but this link is almost never used, but it does exist. // E.g. livestream.com/channelname/share. elseif (!$match && preg_match('@livestream\.com/([0-9a-zA-Z\-]+)/(share)@i', $embedCode, $matches)) { $match = TRUE; $type = 'channel'; $channel_id = $matches[1]; $video_id = $matches[1]; } // This one matches the old flash embed for videos. // E.g. livestream.com/grid/LSPlayer.swf?channel=channelname/clip(id). elseif (!$match && preg_match('@livestream\.com/(grid)/LSPlayer.swf\?(channel)=([0-9a-zA-Z\-]+)&amp;(clipId|clip)=([^\&\'" ]+)@i', $embedCode, $matches)) { $match = TRUE; $type = 'video'; $channel_id = $matches[3]; $video_id = $matches[5]; } // This one matches the old flash embed for channels. // E.g. livestream.com/grid/LSPlayer.swf?channel=channelname. elseif (!$match && preg_match('@livestream\.com/grid/LSPlayer\.swf.?channel=([0-9a-zA-Z\-]+)@i', $embedCode, $matches)) { $match = TRUE; $type = 'channel'; $channel_id = $matches[1]; $video_id = $matches[1]; } //do something with the match (along the lines of validate and return) return array($channel_id, $video_id); } /** * Resolve the Livestream shortcode to get the * full url to the correct channel/video. */ function media_livestream_get_short_code($shortcode) { // Set options to fetch the header redirects Livestream trows at us. $options = array( CURLOPT_HEADER => FALSE, // Don not return headers. Not sure. CURLOPT_FOLLOWLOCATION => TRUE, // Follow the link. CURLOPT_RETURNTRANSFER => TRUE, // This is not what you think. // (see the manual, ^^ still fetches the whole page if i disable it) CURLOPT_ENCODING => "", // Do not specify encoding. CURLOPT_CONNECTTIMEOUT => 100, // Connect timeout. CURLOPT_TIMEOUT => 100, // Response timeout. CURLOPT_MAXREDIRS => 2, // Stop after 2 redirects. CURLOPT_AUTOREFERER => TRUE, // Set the referer on redirect. CURLOPT_USERAGENT => "Drupal", // Browser ID. ); // Initialise curl request. $handler = curl_init($shortcode); curl_setopt_array($handler, $options); // Execute our curl request with our Livesteam shortcode url. $page = curl_exec($handler); $header = curl_getinfo($handler); $errornr = curl_errno($handler); $errormsg = curl_error($handler); // Close request. curl_close($handler); // We don't really need the page content, we're here for the redirect url. $header['page'] = $page; // And we also do not use errors at the moment, but maybe we should. $header['errornr'] = $errornr; $header['errormsg'] = $errormsg; return $header; } print_r(parse('http://www.livestream.com/lukeestv/video?clipId=flv_92609a8d-afa6-4832-a8b2-ac4dc2925f4b&utm_source=lslibrary&utm_medium=ui-thumb'));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.00618.64
8.3.50.0090.00721.99
8.3.40.0090.00618.92
8.3.30.0070.00719.13
8.3.20.0040.00420.20
8.3.10.0040.00422.04
8.3.00.0030.00620.77
8.2.180.0090.00616.88
8.2.170.0120.00322.96
8.2.160.0090.00919.22
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0040.00419.50
8.2.110.0060.00322.39
8.2.100.0040.00819.89
8.2.90.0000.00819.33
8.2.80.0030.00518.16
8.2.70.0030.00617.75
8.2.60.0060.00318.05
8.2.50.0030.00518.07
8.2.40.0030.00518.47
8.2.30.0000.00818.10
8.2.20.0040.00417.86
8.2.10.0040.00417.88
8.2.00.0030.00517.84
8.1.280.0090.00925.92
8.1.270.0000.00822.05
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.00923.85
8.1.230.0070.00418.99
8.1.220.0040.00417.77
8.1.210.0060.00318.77
8.1.200.0100.00017.48
8.1.190.0040.00417.52
8.1.180.0030.00618.86
8.1.170.0080.00018.76
8.1.160.0050.00322.03
8.1.150.0000.00818.85
8.1.140.0050.00317.68
8.1.130.0040.00417.76
8.1.120.0080.00017.71
8.1.110.0040.00417.58
8.1.100.0000.00717.64
8.1.90.0040.00417.56
8.1.80.0040.00417.66
8.1.70.0000.00717.63
8.1.60.0040.00417.78
8.1.50.0040.00417.66
8.1.40.0040.00417.66
8.1.30.0080.00017.82
8.1.20.0030.00617.77
8.1.10.0040.00417.78
8.1.00.0000.00817.73
8.0.300.0000.00718.77
8.0.290.0000.00817.15
8.0.280.0000.00718.50
8.0.270.0020.00517.23
8.0.260.0030.00316.96
8.0.250.0000.00717.15
8.0.240.0040.00417.06
8.0.230.0050.00217.20
8.0.220.0000.00717.09
8.0.210.0000.00817.14
8.0.200.0000.00717.04
8.0.190.0040.00417.20
8.0.180.0040.00417.04
8.0.170.0000.00917.04
8.0.160.0040.00417.17
8.0.150.0000.00817.05
8.0.140.0040.00416.96
8.0.130.0000.00613.58
8.0.120.0030.00617.05
8.0.110.0030.00517.03
8.0.100.0000.00816.98
8.0.90.0080.00017.14
8.0.80.0060.00917.06
8.0.70.0080.00017.18
8.0.60.0000.00816.98
8.0.50.0000.00717.18
8.0.30.0140.00917.32
8.0.20.0070.01417.51
8.0.10.0040.00417.27
8.0.00.0050.01317.04
7.4.330.0000.00515.18
7.4.320.0000.00616.77
7.4.300.0030.00316.86
7.4.290.0030.00316.79
7.4.280.0040.00416.90
7.4.270.0070.00016.91
7.4.260.0000.00916.78
7.4.250.0050.00316.87
7.4.240.0050.00316.77
7.4.230.0050.00316.89
7.4.220.0120.01516.97
7.4.210.0060.00916.86
7.4.200.0030.00516.76
7.4.190.0000.00717.04
7.4.160.0080.00816.89
7.4.150.0100.00717.40
7.4.140.0160.00717.86
7.4.130.0100.00816.84
7.4.120.0130.00416.65
7.4.110.0140.00316.90
7.4.100.0070.01016.82
7.4.90.0100.00716.69
7.4.80.0120.00619.39
7.4.70.0080.01316.72
7.4.60.0110.00616.82
7.4.50.0030.00316.88
7.4.40.0040.00822.77
7.4.30.0100.00916.81
7.4.10.0100.01015.12
7.4.00.0090.00815.19
7.3.330.0030.00313.46
7.3.320.0030.00313.41
7.3.310.0040.00416.50
7.3.300.0040.00416.61
7.3.290.0110.00516.58
7.3.280.0050.01116.58
7.3.270.0090.00917.40
7.3.260.0040.01416.51
7.3.250.0110.00616.71
7.3.240.0070.01716.87
7.3.230.0000.01716.51
7.3.210.0090.00916.89
7.3.200.0070.01419.39
7.3.190.0020.01616.62
7.3.180.0110.00616.92
7.3.170.0090.00916.59
7.3.160.0080.00816.91
7.3.130.0030.01414.69
7.3.120.0050.01115.21
7.3.110.0070.01415.29
7.3.100.0070.00315.02
7.3.90.0070.01015.27
7.3.80.0080.00814.76
7.3.70.0070.01115.20
7.3.60.0070.00714.99
7.3.50.0090.00315.10
7.3.40.0040.01115.14
7.3.30.0080.00415.14
7.3.20.0030.01216.76
7.3.10.0000.01116.91
7.3.00.0030.00716.53
7.2.330.0070.01116.87
7.2.320.0030.01516.76
7.2.310.0070.01016.78
7.2.300.0070.01016.89
7.2.290.0100.00716.94
7.2.260.0040.01515.36
7.2.250.0060.00915.42
7.2.240.0090.00615.52
7.2.230.0030.01015.25
7.2.220.0070.00415.30
7.2.210.0040.01515.25
7.2.200.0040.01415.50
7.2.190.0060.00315.07
7.2.180.0060.00915.55
7.2.170.0070.01115.22
7.2.160.0070.01115.53
7.2.150.0030.01317.04
7.2.140.0060.00616.96
7.2.130.0080.00417.04
7.2.120.0000.01217.03
7.2.110.0030.01016.85
7.2.100.0080.00317.06
7.2.90.0030.01017.16
7.2.80.0100.00317.35
7.2.70.0070.01017.09
7.2.60.0060.01317.34
7.2.50.0040.00817.25
7.2.40.0100.00717.30
7.2.30.0100.00317.01
7.2.20.0090.00317.05
7.2.10.0100.00617.35
7.2.00.0090.00617.10
7.1.330.0030.01015.87
7.1.320.0040.00415.92
7.1.310.0040.01516.00
7.1.300.0000.01316.19
7.1.290.0090.00315.76
7.1.280.0050.00315.85
7.1.270.0000.01416.14
7.1.260.0060.00615.64
7.1.250.0000.01216.00
7.1.240.0040.00816.05
7.1.230.0060.00315.86
7.1.220.0030.01115.85
7.1.210.0000.01616.07
7.1.200.0030.00715.93
7.1.190.0090.00615.85
7.1.180.0030.01515.96
7.1.170.0080.00415.97
7.1.160.0070.01015.95
7.1.150.0000.01616.01
7.1.140.0030.01216.03
7.1.130.0040.00415.81
7.1.120.0030.01016.08
7.1.110.0000.01316.24
7.1.100.0030.01016.03
7.1.90.0110.00316.19
7.1.80.0030.00616.04
7.1.70.0030.01016.74
7.1.60.0050.00716.80
7.1.50.0090.01016.57
7.1.40.0060.00615.88
7.1.30.0060.00616.08
7.1.20.0060.00616.11
7.1.10.0130.00015.92
7.1.00.0030.04519.23
7.0.330.0040.00715.44
7.0.320.0100.00615.74
7.0.310.0100.00715.52
7.0.300.0060.00915.36
7.0.290.0070.00715.46
7.0.280.0000.01015.69
7.0.270.0030.00615.66
7.0.260.0090.00315.27
7.0.250.0070.00315.41
7.0.240.0000.01215.55
7.0.230.0120.00315.58
7.0.220.0120.00615.63
7.0.210.0070.00715.82
7.0.200.0040.00616.19
7.0.190.0030.01015.68
7.0.180.0040.00815.50
7.0.170.0030.01015.25
7.0.160.0040.01115.68
7.0.150.0120.00315.37
7.0.140.0050.04118.73
7.0.130.0120.00315.64
7.0.120.0040.01215.28
7.0.110.0090.00615.71
7.0.100.0070.04317.84
7.0.90.0050.04317.89
7.0.80.0070.03917.74
7.0.70.0030.04017.85
7.0.60.0070.04417.77
7.0.50.0120.03818.01
7.0.40.0070.03216.91
7.0.30.0100.04316.87
7.0.20.0080.04216.79
7.0.10.0060.03516.87
7.0.00.0070.03416.97
5.6.400.0040.01114.68
5.6.390.0060.00614.14
5.6.380.0060.00914.58
5.6.370.0070.01014.70
5.6.360.0030.01314.43
5.6.350.0050.00514.74
5.6.340.0000.01214.72
5.6.330.0090.00313.97
5.6.320.0030.00714.34
5.6.310.0080.00314.38
5.6.300.0030.00714.40
5.6.290.0000.01514.47
5.6.280.0100.03717.61
5.6.270.0040.01214.16
5.6.260.0070.00714.62
5.6.250.0070.03817.74
5.6.240.0030.04317.56
5.6.230.0080.04117.54
5.6.220.0090.04417.73
5.6.210.0100.04617.62
5.6.200.0180.03017.88
5.6.190.0020.04117.81
5.6.180.0050.04417.62
5.6.170.0080.03417.77
5.6.160.0050.03017.69
5.6.150.0140.03817.76
5.6.140.0030.04817.77
5.6.130.0120.04517.73
5.6.120.0080.03717.88
5.6.110.0070.03017.69
5.6.100.0120.04817.70
5.6.90.0060.04817.86
5.6.80.0070.04017.25
5.6.70.0070.02717.47
5.6.60.0120.03517.34
5.6.50.0050.03517.39
5.6.40.0110.04117.46
5.6.30.0030.04717.36
5.6.20.0030.03617.24
5.6.10.0060.04717.34
5.6.00.0030.04717.47
5.5.380.0050.04217.35
5.5.370.0050.04717.30
5.5.360.0100.04517.22
5.5.350.0120.04317.40
5.5.340.0080.04617.53
5.5.330.0080.02517.53
5.5.320.0110.03917.57
5.5.310.0140.03917.75
5.5.300.0120.04017.55
5.5.290.0080.03417.67
5.5.280.0020.04817.54
5.5.270.0080.02617.63
5.5.260.0080.04117.40
5.5.250.0050.04817.54
5.5.240.0060.02417.34
5.5.230.0080.04717.27
5.5.220.0100.04517.33
5.5.210.0120.02717.21
5.5.200.0110.03617.17
5.5.190.0080.04317.27
5.5.180.0070.03317.32
5.5.170.0070.01114.46
5.5.160.0070.02517.22
5.5.150.0070.03917.28
5.5.140.0090.04017.16
5.5.130.0080.02517.34
5.5.120.0080.04417.15
5.5.110.0070.04117.09
5.5.100.0100.02817.28
5.5.90.0120.04017.07
5.5.80.0070.03217.20
5.5.70.0080.04317.13
5.5.60.0080.03817.04
5.5.50.0150.03517.10
5.5.40.0040.04217.14
5.5.30.0140.03717.10
5.5.20.0050.04516.96
5.5.10.0080.04017.19
5.5.00.0070.04017.13
5.4.450.0100.04315.32
5.4.440.0030.04315.29
5.4.430.0000.02715.30
5.4.420.0100.03815.18
5.4.410.0100.03815.09
5.4.400.0050.04615.01
5.4.390.0100.03315.14
5.4.380.0120.03315.13
5.4.370.0040.04415.20
5.4.360.0020.04415.02
5.4.350.0030.04215.09
5.4.340.0090.04115.31
5.4.330.0030.00711.03
5.4.320.0080.03914.91
5.4.310.0020.04315.19
5.4.300.0070.03715.02
5.4.290.0120.03214.90
5.4.280.0030.04515.11
5.4.270.0060.03915.09
5.4.260.0030.03215.22
5.4.250.0080.04015.11
5.4.240.0060.04315.04
5.4.230.0040.03114.82
5.4.220.0080.04014.89
5.4.210.0090.04015.13
5.4.200.0070.04415.14
5.4.190.0070.02614.94
5.4.180.0100.04015.03
5.4.170.0100.03515.04
5.4.160.0060.04014.78
5.4.150.0090.02714.94
5.4.140.0080.03213.76
5.4.130.0070.04013.62
5.4.120.0050.04213.62
5.4.110.0050.02213.68
5.4.100.0020.03613.61
5.4.90.0060.02013.73
5.4.80.0050.02313.90
5.4.70.0060.02013.84
5.4.60.0030.02313.58
5.4.50.0070.01813.88
5.4.40.0080.02013.85
5.4.30.0070.02013.73
5.4.20.0040.02213.74
5.4.10.0010.02413.69
5.4.00.0050.01813.45
5.3.290.0020.04112.73
5.3.280.0070.04012.69
5.3.270.0080.04012.67
5.3.260.0080.02812.52
5.3.250.0050.04112.58
5.3.240.0050.04212.62
5.3.230.0050.03512.61
5.3.220.0080.03712.58
5.3.210.0020.03012.56
5.3.200.0070.02312.66
5.3.190.0020.02812.60
5.3.180.0020.02612.69
5.3.170.0030.02012.70
5.3.160.0000.02412.60
5.3.150.0050.02212.65
5.3.140.0020.02412.69
5.3.130.0090.02212.53
5.3.120.0030.02212.61
5.3.110.0030.02312.72
5.3.100.0050.02312.37
5.3.90.0030.02512.46
5.3.80.0050.02212.27
5.3.70.0040.02112.26
5.3.60.0030.02112.37
5.3.50.0060.01812.29
5.3.40.0030.02312.21
5.3.30.0040.02112.36
5.3.20.0070.01712.22
5.3.10.0030.02111.91
5.3.00.0070.01811.89
5.2.170.0070.02711.28
5.2.160.0030.03011.28
5.2.150.0000.03011.18
5.2.140.0030.02711.27
5.2.130.0030.03311.27
5.2.120.0030.03311.13
5.2.110.0000.02711.03
5.2.100.0030.03311.25
5.2.90.0070.02711.23
5.2.80.0030.03011.13
5.2.70.0030.02711.16
5.2.60.0030.02710.97
5.2.50.0030.03711.17
5.2.40.0030.02711.05
5.2.30.0030.02711.03
5.2.20.0030.03311.06
5.2.10.0030.02311.01
5.2.00.0000.03710.82
5.1.60.0030.02310.08
5.1.50.0030.02310.01
5.1.40.0070.01710.00
5.1.30.0000.02710.30
5.1.20.0000.02710.39
5.1.10.0000.03710.20
5.1.00.0030.02310.18
5.0.50.0000.0238.59
5.0.40.0000.0208.45
5.0.30.0000.0308.40
5.0.20.0000.0208.40
5.0.10.0070.0208.40
5.0.00.0030.0408.40
4.4.90.0030.0138.40
4.4.80.0000.0178.40
4.4.70.0000.0178.40
4.4.60.0070.0108.40
4.4.50.0000.0178.40
4.4.40.0000.0278.40
4.4.30.0000.0178.40
4.4.20.0000.0208.40
4.4.10.0000.0138.40
4.4.00.0030.0238.40
4.3.110.0030.0138.40
4.3.100.0000.0178.40
4.3.90.0000.0138.40
4.3.80.0030.0208.40
4.3.70.0000.0138.40
4.3.60.0030.0138.40
4.3.50.0000.0178.40
4.3.40.0000.0208.40
4.3.30.0030.0138.40
4.3.20.0030.0108.40
4.3.10.0000.0178.40
4.3.00.0000.0178.40

preferences:
50.02 ms | 401 KiB | 5 Q