3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ContentSecurityPolicy { const DEFAULT_SRC = 'default-src'; const SCRIPT_SRC = 'script-src'; const OBJECT_SRC = 'object-src'; const STYLE_SRC = 'style-src'; const IMG_SRC = 'img-src'; const MEDIA_SRC = 'media-src'; const FRAME_SRC = 'frame-src'; const FONT_SRC = 'font-src'; const CONNECT_SRC = 'connect-src'; const SOURCE_NONE = "'none'"; const SOURCE_SELF = "'self'"; const SOURCE_UNSAFE_INLINE = "'unsafe-inline'"; const SOURCE_UNSAFE_EVAL = "'unsafe-eval'"; private $policy; public function __construct() { $this->policy = array(); $this->policy[self::DEFAULT_SRC] = array(); $this->policy[self::SCRIPT_SRC] = array(); $this->policy[self::OBJECT_SRC] = array(); $this->policy[self::STYLE_SRC] = array(); $this->policy[self::IMG_SRC] = array(); $this->policy[self::MEDIA_SRC] = array(); $this->policy[self::FRAME_SRC] = array(); $this->policy[self::FONT_SRC] = array(); $this->policy[self::CONNECT_SRC] = array(); $this->setPolicySourceDirectives(); } private function setPolicySourceDirectives(){ $refl = new ReflectionClass(__CLASS__); $srcPattern = '/.+_SRC$/'; foreach ($refl->getConstants() as $constant => $value){ if (pref_match($srcPattern, $constant)){ print self::$constant . "\n"; } } exit; } private function copy() { $retval = new ContentSecurityPolicy(); foreach ($this->policy as $directive => $sources) { foreach ($sources as $source) { array_push($retval->policy[$directive], $source); } } return $retval; } function addSource($directive, $source) { if (!isset($this->policy[$directive])) { throw new CSPException("Invalid directive"); } $this->policy[$directive][] = $source; return $this; } function toString() { $retval = array(); foreach ($this->policy as $directive => $sources) { if (sizeof($sources) > 0) { $retval[] = join(' ', [$directive, join(' ', $sources)]); } } return join('; ', $retval); } } class CSPException extends \Exception {} $CSP = new ContentSecurityPolicy(); $CSP->addSource(ContentSecurityPolicy::DEFAULT_SRC, ContentSecurityPolicy::SOURCE_SELF) ->addSource(ContentSecurityPolicy::SCRIPT_SRC, ContentSecurityPolicy::SOURCE_SELF) ->addSource(ContentSecurityPolicy::SCRIPT_SRC, 'http://code.jquery.com') ->addSource(ContentSecurityPolicy::STYLE_SRC, ContentSecurityPolicy::SOURCE_SELF) ->addSource(ContentSecurityPolicy::STYLE_SRC, 'https://bootstrapcdn.com') ->addSource(ContentSecurityPolicy::FONT_SRC, 'https://fonts.googleapis.com'); echo $CSP->toString(); exit("\nDone!\n");

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.01118.53
8.3.50.0140.00521.15
8.3.40.0040.01118.71
8.3.30.0000.01420.39
8.3.20.0040.00420.16
8.3.10.0080.00021.95
8.3.00.0060.00322.42
8.2.180.0090.00616.63
8.2.170.0140.00722.96
8.2.160.0100.00322.16
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00420.88
8.2.110.0100.00020.38
8.2.100.0110.00018.16
8.2.90.0040.00418.22
8.2.80.0040.00419.28
8.2.70.0100.00017.75
8.2.60.0080.00017.93
8.2.50.0080.00018.07
8.2.40.0040.00418.34
8.2.30.0040.00419.36
8.2.20.0040.00417.82
8.2.10.0000.00817.75
8.2.00.0000.00817.91
8.1.280.0100.01025.92
8.1.270.0060.00323.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0090.00022.14
8.1.230.0080.00421.03
8.1.220.0050.00317.74
8.1.210.0040.00419.04
8.1.200.0110.00017.35
8.1.190.0000.00817.53
8.1.180.0030.00618.10
8.1.170.0040.00418.66
8.1.160.0030.00618.87
8.1.150.0040.00418.67
8.1.140.0000.00817.46
8.1.130.0000.00817.95
8.1.120.0000.00717.55
8.1.110.0030.00617.53
8.1.100.0000.00817.44
8.1.90.0040.00417.41
8.1.80.0020.00517.40
8.1.70.0000.00717.41
8.1.60.0090.00017.62
8.1.50.0000.00717.57
8.1.40.0070.00317.48
8.1.30.0000.00917.68
8.1.20.0040.00417.68
8.1.10.0050.00317.59
8.1.00.0040.00417.44
8.0.300.0050.00220.35
8.0.290.0000.00817.05
8.0.280.0020.00518.40
8.0.270.0030.00317.35
8.0.260.0030.00316.93
8.0.250.0040.00417.06
8.0.240.0000.01317.05
8.0.230.0070.00017.03
8.0.220.0070.00017.00
8.0.210.0070.00016.88
8.0.200.0030.00317.05
8.0.190.0030.00316.97
8.0.180.0070.00016.94
8.0.170.0080.00017.04
8.0.160.0040.00416.98
8.0.150.0050.00316.98
8.0.140.0060.00316.89
8.0.130.0060.00013.47
8.0.120.0040.00416.97
8.0.110.0040.00416.99
8.0.100.0070.00016.95
8.0.90.0040.00417.01
8.0.80.0040.01216.99
8.0.70.0000.00816.95
8.0.60.0000.00716.80
8.0.50.0070.00016.81
8.0.30.0090.00917.08
8.0.20.0090.00817.40
8.0.10.0040.00417.09
8.0.00.0060.01216.76
7.4.330.0050.00016.84
7.4.320.0040.00416.54
7.4.300.0000.00616.64
7.4.290.0060.00316.65
7.4.280.0030.00316.48
7.4.270.0040.00416.55
7.4.260.0000.00513.25
7.4.250.0050.00316.51
7.4.240.0040.00416.60
7.4.230.0040.00416.73
7.4.220.0110.00616.68
7.4.210.0060.00916.60
7.4.200.0000.00816.73
7.4.190.0070.00016.68
7.4.160.0120.00616.46
7.4.150.0070.01117.40
7.4.140.0090.00817.86
7.4.130.0100.00616.54
7.4.120.0120.00516.64
7.4.110.0120.00616.69
7.4.100.0040.01616.57
7.4.90.0050.01116.73
7.4.80.0110.01119.39
7.4.70.0060.01216.66
7.4.60.0110.00616.53
7.4.50.0030.00316.32
7.4.40.0060.00622.77
7.4.30.0150.00616.56
7.4.00.0070.01014.96
7.3.330.0060.00013.52
7.3.320.0000.00513.27
7.3.310.0070.00016.60
7.3.300.0000.00716.37
7.3.290.0140.00016.41
7.3.280.0050.01116.50
7.3.270.0060.01117.40
7.3.260.0070.01018.24
7.3.250.0080.01016.57
7.3.240.0140.00616.62
7.3.230.0060.01316.40
7.3.210.0140.00716.42
7.3.200.0110.01119.39
7.3.190.0090.00916.59
7.3.180.0100.01016.61
7.3.170.0070.01016.39
7.3.160.0060.01016.50
7.3.120.0090.00814.92
7.3.110.0000.01214.80
7.3.100.0070.00315.15
7.3.90.0110.00414.77
7.3.80.0030.01014.93
7.3.70.0040.00714.83
7.3.60.0130.00014.68
7.3.50.0070.00714.84
7.3.40.0110.00614.86
7.3.30.0060.00914.55
7.3.20.0070.01116.75
7.3.10.0120.00316.44
7.3.00.0090.00716.47
7.2.330.0060.01216.73
7.2.320.0030.01516.51
7.2.310.0150.00316.54
7.2.300.0080.00816.77
7.2.290.0060.01316.75
7.2.250.0060.01215.21
7.2.240.0100.01015.00
7.2.230.0120.00315.17
7.2.220.0030.01315.01
7.2.210.0070.00714.79
7.2.200.0060.00915.25
7.2.190.0090.00614.89
7.2.180.0030.01015.16
7.2.170.0120.00315.18
7.2.130.0100.00516.57
7.2.120.0080.00816.72
7.2.110.0070.01016.63
7.2.100.0080.01216.80
7.2.90.0120.00416.71
7.2.80.0130.00516.70
7.2.70.0120.00916.76
7.2.60.0130.01016.60
7.2.50.0050.01016.57
7.2.40.0100.01016.43
7.2.30.0120.00716.60
7.2.20.0090.00916.67
7.2.10.0130.00616.56
7.2.00.0100.00717.57
7.1.330.0030.01015.42
7.1.320.0080.00615.73
7.1.310.0080.00015.70
7.1.300.0060.01015.88
7.1.290.0000.01815.91
7.1.280.0000.00815.55
7.1.270.0090.00615.86
7.1.260.0060.00315.93
7.1.250.0130.00715.47
7.1.240.0030.00715.42
7.1.230.0090.00615.66
7.1.220.0040.00415.77
7.1.210.0070.00715.65
7.1.200.0030.01015.54
7.1.190.0040.01115.55
7.1.180.0090.00615.34
7.1.170.0130.00715.57
7.1.160.0030.00715.61
7.1.150.0100.00315.89
7.1.140.0070.01115.84
7.1.130.0070.01015.58
7.1.120.0100.01015.69
7.1.110.0060.00615.55
7.1.100.0050.00716.83
7.1.90.0100.00615.83
7.1.80.0040.01115.72
7.1.70.0020.00716.57
7.1.60.0060.01217.50
7.1.50.0060.00616.20
7.1.40.0060.00315.98
7.1.30.0030.00615.55
7.1.20.0100.00315.67
7.1.10.0000.01315.74
7.1.00.0080.01519.12
7.0.330.0080.00315.01
7.0.320.0080.00015.14
7.0.310.0060.00615.02
7.0.300.0000.01714.92
7.0.290.0000.01115.34
7.0.280.0050.00515.48
7.0.270.0000.01015.46
7.0.260.0030.01215.23
7.0.250.0080.00015.43
7.0.240.0060.00315.27
7.0.230.0120.00615.50
7.0.220.0100.00014.88
7.0.210.0120.00315.22
7.0.200.0020.00916.08
7.0.190.0060.01315.32
7.0.180.0110.00315.25
7.0.170.0060.00915.24
7.0.160.0140.00315.01
7.0.150.0030.01014.91
7.0.140.0060.03918.54
7.0.130.0060.00615.41
7.0.120.0000.00815.42
7.0.110.0040.01115.05
7.0.100.0150.03917.70
7.0.90.0070.03017.71
7.0.80.0030.04817.81
7.0.70.0030.03017.52
7.0.60.0050.03017.53
7.0.50.0080.03717.84
7.0.40.0070.04516.61
7.0.30.0120.02316.72
7.0.20.0040.04116.70
7.0.10.0020.03816.60
7.0.00.0110.02316.65
5.6.380.0040.00714.40
5.6.370.0000.01514.66
5.6.360.0000.01114.36
5.6.350.0000.00814.35
5.6.340.0000.01314.46
5.6.330.0070.00714.26
5.6.320.0000.01613.94
5.6.310.0030.01014.25
5.6.300.0030.00614.34
5.6.290.0030.01014.07
5.6.280.0080.00514.31
5.6.270.0000.01614.27
5.6.260.0060.00314.51
5.6.250.0020.04717.32
5.6.240.0070.04217.49
5.6.230.0080.04317.70
5.6.220.0100.03017.47
5.6.210.0110.03817.50
5.6.200.0050.04617.83
5.6.190.0070.04217.60
5.6.180.0020.05117.87
5.6.170.0100.03217.65
5.6.160.0090.04217.80
5.6.150.0060.04117.82
5.6.140.0030.02617.76
5.6.130.0090.04517.60
5.6.120.0070.03017.70
5.6.110.0090.03817.82
5.6.100.0080.02317.59
5.6.90.0110.04417.69
5.6.80.0070.04417.24
5.6.70.0090.02217.35
5.6.60.0120.01817.27
5.6.50.0060.02617.42
5.6.40.0090.02417.32
5.6.30.0110.01917.28
5.6.20.0090.02117.31
5.6.10.0040.02617.31
5.6.00.0000.02517.29
5.5.380.0150.02815.91
5.5.370.0080.03815.76
5.5.360.0050.04515.80
5.5.350.0080.02115.72
5.5.340.0100.03315.87
5.5.330.0050.04315.95
5.5.320.0060.04616.01
5.5.310.0120.03216.10
5.5.300.0040.02516.01
5.5.290.0110.02415.98
5.5.280.0020.04216.06
5.5.270.0080.03116.04
5.5.260.0050.02615.94
5.5.250.0040.02615.90
5.5.240.0070.04315.65
5.5.230.0100.02015.73
5.5.220.0100.01715.67
5.5.210.0040.02415.69
5.5.200.0080.02615.68
5.5.190.0070.02415.63
5.5.180.0030.02615.61
5.5.170.0030.00811.17
5.5.160.0060.02015.77
5.5.150.0150.01715.73
5.5.140.0070.02015.70
5.5.130.0060.01915.80
5.5.120.0040.02715.78
5.5.110.0060.02015.64
5.5.100.0110.02615.79
5.5.90.0090.01715.64
5.5.80.0070.01815.60
5.5.70.0080.02115.59
5.5.60.0050.01915.54
5.5.50.0050.02015.51
5.5.40.0020.02215.52
5.5.30.0070.01715.60
5.5.20.0060.01915.58
5.5.10.0030.02415.58
5.5.00.0050.01815.60
5.4.450.0070.03515.18
5.4.440.0030.04415.21
5.4.430.0080.04315.27
5.4.420.0050.02515.25
5.4.410.0050.03315.07
5.4.400.0080.02015.14
5.4.390.0060.02114.96
5.4.380.0050.02215.12
5.4.370.0030.02215.08
5.4.360.0030.03015.09
5.4.350.0080.02215.04
5.4.340.0020.02615.09
5.4.330.0040.00811.06
5.4.320.0040.01915.08
5.4.310.0020.02015.09
5.4.300.0040.01715.06
5.4.290.0000.02215.12
5.4.280.0040.02015.05
5.4.270.0030.01815.14
5.4.260.0030.02015.10
5.4.250.0090.01915.05
5.4.240.0070.01715.06
5.4.230.0040.01915.13
5.4.220.0050.01915.12
5.4.210.0050.02015.11
5.4.200.0050.02415.05
5.4.190.0030.02015.01
5.4.180.0050.01914.97
5.4.170.0020.02615.19
5.4.160.0070.01715.21
5.4.150.0080.02015.04
5.4.140.0050.02013.79
5.4.130.0030.02013.74
5.4.120.0020.02313.69
5.4.110.0060.01513.81
5.4.100.0060.01613.80
5.4.90.0030.02013.75
5.4.80.0050.01713.78
5.4.70.0080.01613.74
5.4.60.0030.01813.70
5.4.50.0040.01713.76
5.4.40.0020.02213.71
5.4.30.0050.01713.70
5.4.20.0070.03713.77
5.4.10.0080.02113.80
5.4.00.0070.03713.51
5.3.290.0060.02012.88
5.3.280.0020.02012.90
5.3.270.0030.02112.86
5.3.260.0030.02212.92
5.3.250.0020.01912.91
5.3.240.0070.01512.91
5.3.230.0020.02212.83
5.3.220.0050.01812.79
5.3.210.0010.02512.87
5.3.200.0090.01312.90
5.3.190.0050.02112.79
5.3.180.0060.01612.88
5.3.170.0020.02212.81
5.3.160.0040.02612.84
5.3.150.0050.01812.80
5.3.140.0050.01612.89
5.3.130.0020.02112.79
5.3.120.0110.02512.81
5.3.110.0060.03812.79
5.3.100.0030.03012.54
5.3.90.0070.03012.60
5.3.80.0050.03812.50
5.3.70.0030.03412.58
5.3.60.0040.02812.61
5.3.50.0020.02212.53
5.3.40.0040.02012.59
5.3.30.0020.04312.46
5.3.20.0070.03512.39
5.3.10.0070.03212.31
5.3.00.0080.03612.38
5.2.170.0030.03311.65
5.2.160.0040.02611.65
5.2.150.0050.03311.65
5.2.140.0050.03211.65
5.2.130.0060.01711.65
5.2.120.0020.03411.65
5.2.110.0060.03111.65
5.2.100.0050.02911.65
5.2.90.0050.01511.65
5.2.80.0020.03511.65
5.2.70.0030.03311.65
5.2.60.0000.01811.65
5.2.50.0020.03311.65
5.2.40.0010.03511.65
5.2.30.0070.02811.65
5.2.20.0050.01311.65
5.2.10.0000.02811.65
5.2.00.0060.03211.65
5.1.60.0060.02611.65
5.1.50.0000.02611.65
5.1.40.0030.02011.65
5.1.30.0040.01311.65
5.1.20.0070.01211.65
5.1.10.0030.02811.65
5.1.00.0030.01511.65
5.0.50.0030.01111.65
5.0.40.0020.02411.65
5.0.30.0020.03011.65
5.0.20.0050.02211.65
5.0.10.0030.02011.65
5.0.00.0000.03611.65
4.4.90.0030.01311.65
4.4.80.0000.01511.65
4.4.70.0060.00711.65
4.4.60.0070.01311.65
4.4.50.0020.00811.65
4.4.40.0020.01311.65
4.4.30.0020.01811.65
4.4.20.0000.02311.65
4.4.10.0000.01211.65
4.4.00.0040.01211.65
4.3.110.0000.02311.65
4.3.100.0010.01311.65
4.3.90.0000.01311.65
4.3.80.0030.02311.65
4.3.70.0000.01311.65
4.3.60.0000.01111.65
4.3.50.0000.02011.65
4.3.40.0030.01511.65
4.3.30.0030.01011.65
4.3.20.0000.01311.65
4.3.10.0000.02011.65
4.3.00.0020.01811.65

preferences:
43.95 ms | 401 KiB | 5 Q