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' => $channel_id, 'video' => $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://livestre.am/5Un'));

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.40.0120.00319.34
8.3.30.0110.00419.08
8.3.20.0040.00420.32
8.3.10.0080.00021.97
8.3.00.0040.00422.46
8.2.170.0090.00622.96
8.2.160.0040.01119.41
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0030.00619.50
8.2.110.0030.00620.42
8.2.100.0110.00018.18
8.2.90.0050.00319.38
8.2.80.0030.00618.04
8.2.70.0030.00617.88
8.2.60.0080.00018.05
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0040.00418.15
8.2.20.0080.00017.98
8.2.10.0040.00417.93
8.2.00.0040.00417.89
8.1.270.0080.00022.18
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.78
8.1.230.0110.00021.95
8.1.220.0080.00017.79
8.1.210.0000.00818.77
8.1.200.0090.00017.60
8.1.190.0080.00017.54
8.1.180.0040.00418.84
8.1.170.0050.00318.81
8.1.160.0000.01023.77
8.1.150.0040.00418.95
8.1.140.0050.00217.66
8.1.130.0030.00317.83
8.1.120.0040.00417.68
8.1.110.0000.00817.69
8.1.100.0070.00017.56
8.1.90.0050.00217.64
8.1.80.0000.00717.53
8.1.70.0070.00017.55
8.1.60.0030.00617.72
8.1.50.0030.00617.64
8.1.40.0040.00417.68
8.1.30.0000.00817.80
8.1.20.0030.00617.78
8.1.10.0040.00417.74
8.1.00.0040.00417.70
8.0.300.0060.00318.77
8.0.290.0070.00017.30
8.0.280.0000.00818.52
8.0.270.0000.00717.34
8.0.260.0000.00716.95
8.0.250.0040.00417.14
8.0.240.0000.00717.25
8.0.230.0040.00417.23
8.0.220.0000.00817.06
8.0.210.0000.00717.11
8.0.200.0070.00017.13
8.0.190.0090.00017.14
8.0.180.0000.00817.07
8.0.170.0030.00617.11
8.0.160.0040.00417.20
8.0.150.0030.00717.11
8.0.140.0000.00717.10
8.0.130.0030.00313.68
8.0.120.0000.00817.02
8.0.110.0080.00017.16
8.0.100.0000.00817.10
8.0.90.0030.00617.18
8.0.80.0090.00617.14
8.0.70.0050.00317.06
8.0.60.0080.00016.96
8.0.50.0000.00717.25
8.0.30.0140.00517.44
8.0.20.0110.01017.40
8.0.10.0000.00817.14
8.0.00.0120.00617.09
7.4.330.0060.00015.02
7.4.320.0000.00616.77
7.4.300.0040.00416.73
7.4.290.0030.00616.80
7.4.280.0070.00016.68
7.4.270.0070.00016.86
7.4.260.0040.00416.82
7.4.250.0030.00616.84
7.4.240.0040.00416.83
7.4.230.0030.00516.95
7.4.220.0130.00316.90
7.4.210.0090.00816.84
7.4.200.0000.00717.00
7.4.190.0000.00716.69
7.4.160.0100.00716.89
7.4.150.0100.00817.40
7.4.140.0140.00717.86
7.4.130.0080.01016.84
7.4.120.0080.00916.88
7.4.110.0150.00416.77
7.4.100.0100.01016.91
7.4.90.0000.01716.67
7.4.80.0150.00519.39
7.4.70.0070.01416.83
7.4.60.0140.00316.59
7.4.50.0040.00416.75
7.4.40.0040.01222.77
7.4.30.0090.00916.95
7.4.00.0040.01215.37
7.3.330.0030.00313.66
7.3.320.0030.00313.41
7.3.310.0040.00416.61
7.3.300.0040.00416.56
7.3.290.0040.01116.54
7.3.280.0080.00916.59
7.3.270.0090.00917.40
7.3.260.0060.01216.53
7.3.250.0100.01216.68
7.3.240.0120.00616.65
7.3.230.0160.00616.88
7.3.210.0120.00616.80
7.3.200.0070.01019.39
7.3.190.0080.00916.65
7.3.180.0160.00316.82
7.3.170.0080.00816.74
7.3.160.0030.01216.99
7.3.120.0100.00715.06
7.2.330.0070.01117.02
7.2.320.0110.01116.77
7.2.310.0090.00916.95
7.2.300.0110.00616.87
7.2.290.0060.01216.79
7.2.60.0260.00317.05
7.2.00.0040.01119.77
7.1.200.0080.00515.83
7.1.100.0000.00818.18
7.1.70.0050.00517.49
7.1.60.0130.01319.82
7.1.50.0100.01017.20
7.1.00.0100.07322.33
7.0.200.0060.00316.66
7.0.140.0030.07322.12
7.0.60.0070.04720.19
7.0.50.0170.07317.96
7.0.40.0130.08020.14
7.0.30.0200.04020.26
7.0.20.0300.08020.20
7.0.10.0070.04020.22
7.0.00.0100.03720.18
5.6.280.0030.07320.92
5.6.210.0070.03720.50
5.6.200.0130.06018.32
5.6.190.0170.07020.57
5.6.180.0300.04020.52
5.6.170.0330.06720.46
5.6.160.0200.07320.57
5.6.150.0030.04318.17
5.6.140.0100.07718.25
5.6.130.0030.09018.18
5.6.120.0100.07721.04
5.6.110.0030.07021.14
5.6.100.0200.07321.00
5.6.90.0100.05321.15
5.6.80.0170.06720.39
5.6.70.4500.04320.41
5.5.350.0030.09020.34
5.5.340.0070.08017.95
5.5.330.0000.06720.30
5.5.320.0300.07720.31
5.5.310.0270.05720.35
5.5.300.0030.08317.96
5.5.290.0070.08717.97
5.5.280.0000.08720.71
5.5.270.0130.03720.82
5.5.260.0100.03720.79
5.5.250.0070.06320.71
5.5.240.0030.08320.29
5.4.450.0570.05719.61
5.4.440.0300.05019.59
5.4.430.0370.06019.57
5.4.420.0500.05719.70
5.4.410.0500.05019.18
5.4.400.1000.00018.78
5.4.390.0830.00018.75
5.4.380.0330.07018.80
5.4.370.0270.05018.63
5.4.360.0330.04018.53
5.4.350.0270.05718.72
5.4.340.0270.05018.57
5.4.320.0070.04012.53
5.4.310.0100.04312.52
5.4.300.0050.04112.53
5.4.290.0050.03912.53
5.4.280.0090.03212.42
5.4.270.0070.03712.42
5.4.260.0130.05318.96
5.4.250.0130.07718.99
5.4.240.0070.07719.10
5.4.230.0000.06718.96
5.4.220.0070.05318.88
5.4.210.0130.06718.99
5.4.200.0000.05719.09
5.4.190.0070.05318.73
5.4.180.0200.04018.94
5.4.170.0070.05318.74
5.4.160.0130.04718.63
5.4.150.0100.05318.94
5.4.140.0000.05716.40
5.4.130.0070.05016.30
5.4.120.0130.04316.38
5.4.110.0100.05016.60
5.4.100.0130.04716.44
5.4.90.0030.05316.67
5.4.80.0030.05316.42
5.4.70.0100.04716.46
5.4.60.0130.04716.31
5.4.50.0070.05016.48
5.4.40.0170.04016.38
5.4.30.0100.04316.43
5.4.20.0030.05716.50
5.4.10.0070.07316.36
5.4.00.0000.05715.96
5.3.290.0050.04912.80
5.3.280.0000.05714.60
5.3.270.0100.05014.74
5.3.260.0030.07014.62
5.3.250.0030.05714.70
5.3.240.0070.05014.72
5.3.230.0070.05014.64
5.3.220.0170.04014.68
5.3.210.0170.04314.42
5.3.200.0130.04314.81
5.3.190.0100.04714.68
5.3.180.0130.04014.66
5.3.170.0030.05314.61
5.3.160.0100.04714.42
5.3.150.0030.05714.68
5.3.140.0030.05314.41
5.3.130.0070.05314.65
5.3.120.0030.05714.73
5.3.110.0200.06314.56
5.3.100.0070.05014.05
5.3.90.0130.07014.13
5.3.80.0070.07014.13
5.3.70.0100.04714.11
5.3.60.0200.04014.11
5.3.50.0070.05014.05
5.3.40.0100.05313.99
5.3.30.0070.04714.11
5.3.20.0070.05013.80
5.3.10.0070.05013.50
5.3.00.0170.04013.89
5.2.170.0030.04311.34
5.2.160.0070.04011.01
5.2.150.0070.04011.08
5.2.140.0000.04711.14
5.2.130.0100.03711.21
5.2.120.0070.03711.21
5.2.110.0000.04311.09
5.2.100.0070.03711.20
5.2.90.0100.04011.30
5.2.80.0070.06011.30
5.2.70.0000.04711.11
5.2.60.0070.04711.06
5.2.50.0030.06310.96
5.2.40.0030.05311.03
5.2.30.0030.04311.08
5.2.20.0100.05011.05
5.2.10.0100.04310.89
5.2.00.0000.04710.74
5.1.60.0030.0379.95
5.1.50.0100.03010.07
5.1.40.0100.03010.00
5.1.30.0100.04710.45
5.1.20.0070.04710.38
5.1.10.0070.03310.06
5.1.00.0100.03310.03
5.0.50.0000.0338.83
5.0.40.0100.0338.30
5.0.30.0070.0408.19
5.0.20.0030.0278.43
5.0.10.0070.0238.22
5.0.00.0030.0438.17
4.4.90.0000.0235.93
4.4.80.0000.0275.91
4.4.70.0000.0275.93
4.4.60.0030.0305.88
4.4.50.0000.0235.95
4.4.40.0030.0335.93
4.4.30.0070.0175.92
4.4.20.0030.0236.09
4.4.10.0000.0236.00
4.4.00.0030.0305.95
4.3.110.0000.0335.81
4.3.100.0100.0135.86
4.3.90.0070.0275.83
4.3.80.0070.0305.79
4.3.70.0030.0275.83
4.3.60.0030.0305.82
4.3.50.0070.0205.80
4.3.40.0000.0375.79
4.3.30.0070.0175.32
4.3.20.0000.0235.32
4.3.10.0030.0205.32
4.3.00.0070.0239.25

preferences:
46.6 ms | 400 KiB | 5 Q