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('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.0070.01518.43
8.3.50.0070.01321.97
8.3.40.0060.00918.92
8.3.30.0110.00319.07
8.3.20.0050.00320.39
8.3.10.0060.00321.87
8.3.00.0040.00422.43
8.2.180.0110.01417.00
8.2.170.0110.00422.96
8.2.160.0140.00019.29
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0110.00426.16
8.2.120.0050.00319.61
8.2.110.0030.01322.26
8.2.100.0090.00319.70
8.2.90.0030.00619.47
8.2.80.0000.00818.17
8.2.70.0110.00018.00
8.2.60.0040.00418.05
8.2.50.0040.00418.07
8.2.40.0040.00418.28
8.2.30.0040.00418.29
8.2.20.0040.00417.82
8.2.10.0060.00317.98
8.2.00.0040.00417.98
8.1.280.0140.00725.92
8.1.270.0080.00022.10
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0040.00423.75
8.1.230.0060.00619.35
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0070.00317.48
8.1.190.0040.00417.65
8.1.180.0040.00418.69
8.1.170.0060.00318.80
8.1.160.0090.00022.11
8.1.150.0030.00618.86
8.1.140.0040.00417.72
8.1.130.0030.00317.93
8.1.120.0030.00517.58
8.1.110.0060.00317.70
8.1.100.0050.00217.59
8.1.90.0040.00417.71
8.1.80.0040.00417.67
8.1.70.0030.00317.64
8.1.60.0040.00417.79
8.1.50.0080.00017.81
8.1.40.0000.00817.76
8.1.30.0050.00317.86
8.1.20.0040.00417.86
8.1.10.0000.00817.71
8.1.00.0060.00317.74
8.0.300.0080.00018.77
8.0.290.0040.00417.28
8.0.280.0040.00418.54
8.0.270.0000.00817.27
8.0.260.0070.00017.08
8.0.250.0030.00417.07
8.0.240.0040.00417.08
8.0.230.0040.00417.14
8.0.220.0030.00317.16
8.0.210.0040.00417.02
8.0.200.0040.00417.14
8.0.190.0040.00417.15
8.0.180.0000.00817.14
8.0.170.0070.00317.14
8.0.160.0040.00417.04
8.0.150.0060.00317.05
8.0.140.0030.00616.97
8.0.130.0040.00413.49
8.0.120.0030.00717.09
8.0.110.0040.00417.05
8.0.100.0040.00417.10
8.0.90.0050.00316.89
8.0.80.0030.01817.07
8.0.70.0000.00817.16
8.0.60.0080.00017.02
8.0.50.0000.00817.13
8.0.30.0100.01017.42
8.0.20.0050.01417.43
8.0.10.0080.00017.12
8.0.00.0060.01216.93
7.4.330.0030.00315.00
7.4.320.0000.00816.80
7.4.300.0000.00616.80
7.4.290.0030.00716.81
7.4.280.0070.00016.81
7.4.270.0030.00316.82
7.4.260.0000.00716.79
7.4.250.0040.00416.88
7.4.240.0040.00316.82
7.4.230.0040.00416.78
7.4.220.0130.00616.86
7.4.210.0060.00816.92
7.4.200.0000.00716.68
7.4.190.0040.00416.99
7.4.160.0100.00616.57
7.4.150.0100.01017.40
7.4.140.0150.00817.86
7.4.130.0060.01316.60
7.4.120.0100.00716.92
7.4.110.0100.00716.90
7.4.100.0120.00616.86
7.4.90.0110.00716.54
7.4.80.0110.00719.39
7.4.70.0080.01116.86
7.4.60.0070.01316.71
7.4.50.0030.00516.55
7.4.40.0060.00322.77
7.4.30.0090.00916.72
7.4.10.0110.00715.20
7.4.00.0050.01115.28
7.3.330.0000.00513.62
7.3.320.0030.00313.61
7.3.310.0060.00316.64
7.3.300.0040.00416.47
7.3.290.0120.00616.62
7.3.280.0060.01016.54
7.3.270.0030.01317.40
7.3.260.0150.00316.83
7.3.250.0100.00816.78
7.3.240.0130.00416.62
7.3.230.0090.00916.65
7.3.210.0090.00916.50
7.3.200.0130.00519.39
7.3.190.0150.00616.86
7.3.180.0100.01016.45
7.3.170.0000.01616.72
7.3.160.0000.01716.74
7.3.130.0110.00715.44
7.3.120.0080.01015.01
7.3.110.0160.00315.24
7.3.100.0100.00315.20
7.3.90.0120.00315.20
7.3.80.0050.00515.20
7.3.70.0040.00815.20
7.3.60.0060.00615.20
7.3.50.0000.01215.22
7.3.40.0070.00415.20
7.3.30.0080.00415.20
7.3.20.0080.00817.05
7.3.10.0120.00416.78
7.3.00.0020.00916.75
7.2.330.0090.00916.96
7.2.320.0120.00616.99
7.2.310.0090.00916.89
7.2.300.0060.01616.90
7.2.290.0160.00617.14
7.2.260.0080.00815.20
7.2.250.0070.01015.38
7.2.240.0120.00315.20
7.2.230.0000.01315.50
7.2.220.0040.00815.41
7.2.210.0070.01015.32
7.2.200.0090.00615.48
7.2.190.0060.00915.56
7.2.180.0060.00915.49
7.2.170.0030.01015.26
7.2.160.0030.01315.29
7.2.150.0090.00917.07
7.2.140.0100.00317.07
7.2.130.0050.00816.98
7.2.120.0020.01117.22
7.2.110.0060.00517.20
7.2.100.0050.00817.10
7.2.90.0090.00316.98
7.2.80.0080.00816.93
7.2.70.0050.01217.00
7.2.60.0040.01217.13
7.2.50.0060.00717.22
7.2.40.0030.01017.11
7.2.30.0080.00617.02
7.2.20.0060.00516.86
7.2.10.0000.01217.22
7.2.00.0050.01018.10
7.1.330.0030.01016.08
7.1.320.0030.00616.13
7.1.310.0000.00916.19
7.1.300.0000.01416.00
7.1.290.0060.01215.98
7.1.280.0030.00616.02
7.1.270.0030.00616.23
7.1.260.0070.01115.96
7.1.250.0020.01116.02
7.1.240.0050.00516.16
7.1.230.0060.00515.93
7.1.220.0060.00915.90
7.1.210.0050.01015.94
7.1.200.0070.00815.95
7.1.190.0050.00716.06
7.1.180.0030.01315.97
7.1.170.0100.00315.93
7.1.160.0080.00715.77
7.1.150.0030.01215.92
7.1.140.0060.00616.01
7.1.130.0050.00715.93
7.1.120.0070.00615.97
7.1.110.0080.00416.04
7.1.100.0070.00516.94
7.1.90.0050.00916.13
7.1.80.0000.01215.99
7.1.70.0020.01216.42
7.1.60.0080.01017.38
7.1.50.0060.00816.36
7.1.40.0110.00315.93
7.1.30.0070.00515.95
7.1.20.0090.00715.97
7.1.10.0060.00715.89
7.1.00.0050.03018.07
7.0.330.0070.00615.51
7.0.320.0090.00515.39
7.0.310.0040.01015.72
7.0.300.0020.01015.51
7.0.290.0080.00315.58
7.0.280.0080.00715.78
7.0.270.0050.00815.48
7.0.260.0090.00715.62
7.0.250.0050.00615.71
7.0.240.0040.00915.69
7.0.230.0080.00515.60
7.0.220.0050.00715.69
7.0.210.0060.00815.70
7.0.200.0050.00516.07
7.0.190.0020.01015.54
7.0.180.0110.00315.47
7.0.170.0080.00615.36
7.0.160.0030.00815.66
7.0.150.0060.00915.71
7.0.140.0070.02517.68
7.0.130.0060.00815.51
7.0.120.0110.00415.54
7.0.110.0080.00715.63
7.0.100.0080.00515.54
7.0.90.0030.00915.75
7.0.80.0040.00515.74
7.0.70.0070.00515.65
7.0.60.0050.03217.10
7.0.50.0040.02116.37
7.0.40.0080.03216.34
7.0.30.0170.02316.26
7.0.20.0160.02016.31
7.0.10.0160.03016.44
7.0.00.0060.03416.30
5.6.400.0090.00015.20
5.6.390.0060.00315.20
5.6.380.0050.00714.62
5.6.370.0080.00314.86
5.6.360.0020.01015.00
5.6.350.0050.00714.67
5.6.340.0090.00514.79
5.6.330.0050.01014.76
5.6.320.0080.00614.79
5.6.310.0000.01114.71
5.6.300.0050.00714.92
5.6.290.0040.01114.89
5.6.280.0030.03017.06
5.6.270.0030.00814.80
5.6.260.0040.01214.78
5.6.250.0050.01114.82
5.6.240.0020.00914.79
5.6.230.0050.01014.74
5.6.220.0020.01114.86
5.6.210.0090.02716.74
5.6.200.0080.01715.88
5.6.190.0090.02816.77
5.6.180.1350.02216.72
5.6.170.0190.02516.67
5.6.160.0060.02116.66
5.6.150.0090.03115.91
5.6.140.0010.03615.94
5.6.130.0060.02215.93
5.6.120.0020.03816.91
5.6.110.0030.03616.80
5.6.100.0070.01816.84
5.6.90.0080.01616.86
5.6.80.0050.03316.58
5.6.70.0140.03116.59
5.6.60.0040.01114.71
5.6.50.0040.01114.66
5.6.40.0050.00814.66
5.6.30.0030.01214.86
5.6.20.0060.01114.69
5.6.10.0100.00814.90
5.6.00.0050.01014.64
5.5.380.0080.00513.16
5.5.370.0060.00413.20
5.5.360.0040.01013.27
5.5.350.0020.03415.62
5.5.340.0030.02214.92
5.5.330.0030.02115.52
5.5.320.0130.01615.54
5.5.310.0140.01815.50
5.5.300.0080.02814.76
5.5.290.0060.03414.87
5.5.280.0030.02115.69
5.5.270.0030.02415.83
5.5.260.0020.02015.78
5.5.250.0040.03015.61
5.5.240.0020.02815.59
5.5.230.0020.00913.24
5.5.220.0020.00513.15
5.5.210.0030.00713.09
5.5.200.0050.00713.21
5.5.190.0030.00913.06
5.5.180.0010.01113.26
5.5.170.0050.00713.04
5.5.160.0080.00513.14
5.5.150.0030.00913.03
5.5.140.0040.00813.04
5.5.130.0040.00813.19
5.5.120.0050.00513.05
5.5.110.0090.00513.13
5.5.100.0020.01213.24
5.5.90.0050.00613.09
5.5.80.0010.01013.10
5.5.70.0040.00613.01
5.5.60.0040.00613.20
5.5.50.0030.00813.21
5.5.40.0070.00413.21
5.5.30.0090.00413.25
5.5.20.0050.00713.15
5.5.10.0070.00313.23
5.5.00.0020.01013.17
5.4.450.2170.02115.34
5.4.440.0190.02715.39
5.4.430.0080.02115.21
5.4.420.0070.02115.23
5.4.410.0050.02315.29
5.4.400.0270.00314.96
5.4.390.0220.00615.00
5.4.380.0170.01814.95
5.4.370.0140.02114.99
5.4.360.0090.02615.05
5.4.350.0080.02315.00
5.4.340.0130.02214.95
5.4.330.0020.00413.14
5.4.320.0020.01812.89
5.4.310.0040.01812.93
5.4.300.0050.01813.01
5.4.290.0040.01712.92
5.4.280.0040.01612.96
5.4.270.0060.01412.98
5.4.260.0070.02114.97
5.4.250.0090.02315.10
5.4.240.0060.02815.15
5.4.230.0120.02414.99
5.4.220.0040.02715.09
5.4.210.0070.02315.15
5.4.200.0060.02214.97
5.4.190.0090.01914.98
5.4.180.0020.02215.06
5.4.170.0120.01815.12
5.4.160.0090.02614.98
5.4.150.0080.02114.98
5.4.140.0010.02514.24
5.4.130.0050.01814.15
5.4.120.0050.01914.31
5.4.110.0030.03114.29
5.4.100.0070.02614.23
5.4.90.0080.01914.20
5.4.80.0030.02314.10
5.4.70.0030.02014.29
5.4.60.0040.01914.29
5.4.50.0020.02214.24
5.4.40.0040.02114.24
5.4.30.0060.02414.26
5.4.20.0080.02514.31
5.4.10.0040.02214.21
5.4.00.0070.02213.98
5.3.290.0040.01712.93
5.3.280.0030.02013.38
5.3.270.0060.02213.40
5.3.260.0030.02613.52
5.3.250.0070.02813.51
5.3.240.0070.02113.47
5.3.230.0020.02313.53
5.3.220.0040.02313.46
5.3.210.0060.02613.45
5.3.200.0060.02013.49
5.3.190.0030.02213.43
5.3.180.0080.01713.43
5.3.170.0040.02213.56
5.3.160.0070.01813.42
5.3.150.0060.01913.57
5.3.140.0030.02213.54
5.3.130.0070.02013.45
5.3.120.0040.02313.50
5.3.110.0040.02013.48
5.3.100.0040.01913.37
5.3.90.0070.02413.31
5.3.80.0090.02213.28
5.3.70.0050.02513.22
5.3.60.0050.02013.27
5.3.50.0030.02213.30
5.3.40.0040.01913.28
5.3.30.0060.02113.27
5.3.20.0060.01813.16
5.3.10.0060.01713.06
5.3.00.0020.02613.09
5.2.170.0030.02510.66
5.2.160.0100.02210.54
5.2.150.0050.02310.54
5.2.140.0020.03510.55
5.2.130.0020.02410.58
5.2.120.0020.02310.44
5.2.110.0020.02610.57
5.2.100.0040.02210.44
5.2.90.0080.02010.57
5.2.80.0050.02210.60
5.2.70.0030.02310.63
5.2.60.0050.02810.49
5.2.50.0050.02210.48
5.2.40.0020.02410.40
5.2.30.0020.02710.42
5.2.20.0050.02510.45
5.2.10.0050.02810.49
5.2.00.0070.02010.38
5.1.60.0080.0229.96
5.1.50.0030.0189.98
5.1.40.0050.02010.04
5.1.30.0060.02710.23
5.1.20.0060.01910.07
5.1.10.0050.01910.05
5.1.00.0050.01910.06
5.0.50.0050.0209.25
5.0.40.0070.0179.16
5.0.30.0080.0209.15
5.0.20.0050.0199.06
5.0.10.0000.0269.07
5.0.00.0000.0258.99
4.4.90.0000.0157.96
4.4.80.0030.0167.95
4.4.70.0020.0137.95
4.4.60.0010.0137.98
4.4.50.0030.0137.93
4.4.40.0030.0217.90
4.4.30.0010.0197.90
4.4.20.0030.0157.93
4.4.10.0030.0127.93
4.4.00.0020.0237.93
4.3.110.0050.0098.15
4.3.100.0020.0158.15
4.3.90.0040.0128.15
4.3.80.0080.0158.15
4.3.70.0030.0178.15
4.3.60.0060.0108.15
4.3.50.0050.0108.15
4.3.40.0050.0228.15
4.3.30.0050.0108.15
4.3.20.0010.0148.15
4.3.10.0030.0178.15
4.3.00.0070.0129.60

preferences:
37.7 ms | 401 KiB | 5 Q