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->setPolicySourceDirectives(); } private function setPolicySourceDirectives(){ $refl = new ReflectionClass(__CLASS__); $srcPattern = '/.+_SRC$/'; foreach ($refl->getConstants() as $constant => $value){ if (preg_match($srcPattern, $constant)){ $this->policy[constant(__CLASS__.'::'.$constant)] = array(); } } } 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); } public 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; 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.40.0060.00919.18
8.3.30.0160.00019.14
8.3.20.0080.00018.99
8.3.10.0080.00019.02
8.3.00.0040.00819.51
8.2.170.0190.00322.96
8.2.160.0090.00621.18
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0030.00520.60
8.2.110.0030.00620.38
8.2.100.0080.00318.16
8.2.90.0060.00319.34
8.2.80.0070.00019.39
8.2.70.0030.00618.00
8.2.60.0000.00818.05
8.2.50.0060.00318.07
8.2.40.0060.00318.22
8.2.30.0000.00818.06
8.2.20.0060.00317.84
8.2.10.0000.00817.96
8.2.00.0040.00417.98
8.1.270.0040.00424.66
8.1.260.0090.00926.35
8.1.250.0000.00728.09
8.1.240.0060.00322.71
8.1.230.0120.00021.04
8.1.220.0060.00217.79
8.1.210.0040.00419.10
8.1.200.0100.00017.48
8.1.190.0080.00017.65
8.1.180.0050.00518.10
8.1.170.0000.00818.81
8.1.160.0000.00818.86
8.1.150.0040.00418.86
8.1.140.0050.00317.66
8.1.130.0000.00817.75
8.1.120.0000.00717.63
8.1.110.0050.00317.61
8.1.100.0000.00717.66
8.1.90.0000.00717.60
8.1.80.0050.00217.68
8.1.70.0070.00017.52
8.1.60.0060.00317.75
8.1.50.0040.00417.54
8.1.40.0080.00017.68
8.1.30.0040.00417.85
8.1.20.0030.00517.83
8.1.10.0040.00417.72
8.1.00.0050.00317.67
8.0.300.0040.00419.95
8.0.290.0000.00716.88
8.0.280.0070.00018.50
8.0.270.0070.00017.24
8.0.260.0070.00016.96
8.0.250.0040.00417.20
8.0.240.0020.00517.08
8.0.230.0050.00217.17
8.0.220.0000.00817.20
8.0.210.0000.00717.11
8.0.200.0050.00317.08
8.0.190.0040.00417.21
8.0.180.0040.00417.17
8.0.170.0030.00717.11
8.0.160.0040.00417.23
8.0.150.0000.00817.06
8.0.140.0050.00317.05
8.0.130.0040.00413.53
8.0.120.0040.00417.05
8.0.110.0030.00617.18
8.0.100.0030.00617.19
8.0.90.0040.00417.00
8.0.80.0120.00917.17
8.0.70.0070.00016.92
8.0.60.0050.00316.99
8.0.50.0040.00416.98
8.0.30.0130.00617.25
8.0.20.0080.01117.26
8.0.10.0050.00317.08
8.0.00.0100.00817.00
7.4.330.0060.00013.35
7.4.320.0030.00316.84
7.4.300.0000.00716.87
7.4.290.0050.00316.77
7.4.280.0080.00016.86
7.4.270.0020.00516.87
7.4.260.0060.00013.57
7.4.250.0040.00416.83
7.4.240.0020.00516.87
7.4.230.0030.00316.84
7.4.220.0220.00416.65
7.4.210.0090.00716.76
7.4.200.0030.00516.86
7.4.190.0000.00716.82
7.4.160.0160.00616.80
7.4.150.0140.00616.91
7.4.140.0080.01116.79
7.4.130.0070.01016.72
7.4.120.0110.01116.73
7.4.110.0090.00916.75
7.4.100.0120.01216.66
7.4.90.0160.00016.76
7.4.80.0060.01619.39
7.4.70.0040.01316.78
7.4.60.0060.01016.79
7.4.50.0060.00616.51
7.4.40.0090.00916.74
7.4.30.0130.00916.66
7.4.00.0040.01115.19
7.3.330.0000.00713.48
7.3.320.0050.00013.62
7.3.310.0040.00416.65
7.3.300.0030.00316.55
7.3.290.0100.00716.63
7.3.280.0050.01116.62
7.3.270.0060.01016.62
7.3.260.0120.00616.83
7.3.250.0130.00616.71
7.3.240.0110.00716.82
7.3.230.0190.00016.81
7.3.210.0080.01116.66
7.3.200.0060.01116.88
7.3.190.0060.01616.68
7.3.180.0060.00916.84
7.3.170.0070.01016.66
7.3.160.0030.01316.70
7.3.120.0000.01515.10
7.2.330.0150.00416.87
7.2.320.0030.01416.89
7.2.310.0120.00616.82
7.2.300.0070.01616.70
7.2.290.0110.00516.91
7.2.00.0100.00619.72
7.1.100.0220.00018.30
7.1.70.0020.00517.42
7.1.60.0070.01619.40
7.1.50.0100.01417.11
7.1.00.0030.03322.53
7.0.200.0050.00216.88
7.0.140.0070.07021.95
7.0.120.0070.03022.05
7.0.60.0070.08319.90
7.0.50.0100.05317.97
7.0.40.0130.04017.74
7.0.30.0100.08017.71
7.0.20.0200.05717.77
7.0.10.0070.06017.70
7.0.00.0030.05317.85
5.6.280.0030.07321.13
5.6.210.0200.05020.65
5.6.200.0130.07718.14
5.6.190.0030.07718.28
5.6.180.0070.08018.19
5.6.170.0000.05318.28
5.6.160.0100.07718.21
5.6.150.0130.07318.18
5.6.140.0100.07018.21
5.6.130.0100.04018.21
5.6.120.0130.08318.25
5.6.110.0070.08718.18
5.6.100.0170.05018.18
5.6.90.0030.04718.15
5.6.80.0100.07017.55
5.6.70.0070.07717.57
5.6.60.0070.08317.51
5.6.50.0030.06317.55
5.6.40.0030.08017.51
5.6.30.0070.05017.57
5.6.20.0070.07317.63
5.6.10.0070.07317.66
5.6.00.0030.07717.63
5.5.350.0400.06320.43
5.5.340.0000.09018.09
5.5.330.0070.08018.07
5.5.320.0070.08017.99
5.5.310.0030.04317.96
5.5.300.0070.06317.99
5.5.290.0070.07317.91
5.5.280.0130.08018.04
5.5.270.0000.07317.98
5.5.260.0030.07718.04
5.5.250.0070.05317.89
5.5.240.0030.07317.41
5.5.230.0030.04317.32
5.5.220.0000.05317.37
5.5.210.0070.08017.36
5.5.200.0030.04017.41
5.5.190.0070.08017.30
5.5.180.0170.06317.43
5.5.160.0100.07317.32
5.5.150.0070.07317.41
5.5.140.0130.07017.44
5.5.130.0170.05017.32
5.5.120.0170.03717.31
5.5.110.0030.08017.43
5.5.100.0100.07017.23
5.5.90.0070.05317.20
5.5.80.0070.07317.27
5.5.70.0130.06317.20
5.5.60.0200.05717.23
5.5.50.0100.07317.31
5.5.40.0000.08017.18
5.5.30.0070.08017.18
5.5.20.0000.07717.30
5.5.10.0000.08717.22
5.5.00.0070.07017.31
5.4.450.0230.06319.47
5.4.440.0130.07719.23
5.4.430.0070.05319.39
5.4.420.0170.07019.67
5.4.410.0000.05319.46
5.4.400.0130.07019.05
5.4.390.0070.05319.09
5.4.380.0170.07019.10
5.4.370.0070.06019.02
5.4.360.0130.05319.04
5.4.350.0070.05319.03
5.4.340.0100.04019.02
5.4.320.0000.06718.98
5.4.310.0200.06319.01
5.4.300.0070.06319.12
5.4.290.0100.06319.03
5.4.280.0000.08719.28
5.4.270.0030.04019.09
5.4.260.0070.07719.05
5.4.250.0030.07318.96
5.4.240.0130.07319.09
5.4.230.0100.07718.95
5.4.220.0170.06319.03
5.4.210.0070.08019.00
5.4.200.0130.06719.12
5.4.190.0100.08019.00
5.4.180.0030.08019.26
5.4.170.0070.05319.04
5.4.160.0100.05018.97
5.4.150.0100.05019.09
5.4.140.0030.04716.60
5.4.130.0100.06716.35
5.4.120.0000.05016.58
5.4.110.0030.07716.43
5.4.100.0070.05316.61
5.4.90.0070.07316.52
5.4.80.0030.07716.50
5.4.70.0000.07016.42
5.4.60.0070.05016.30
5.4.50.0030.03316.37
5.4.40.0070.03016.58
5.4.30.0030.03716.47
5.4.20.0070.03316.52
5.4.10.0000.03716.41
5.4.00.0070.03015.84
5.3.290.0100.07314.73
5.3.280.0070.06314.61
5.3.270.0100.07014.68
5.3.260.0070.07714.64
5.3.250.0030.07714.63
5.3.240.0100.07714.63
5.3.230.0070.07014.63
5.3.220.0070.07714.68
5.3.210.0030.07014.58
5.3.200.0100.07014.55
5.3.190.0070.06714.66
5.3.180.0030.07714.57
5.3.170.0030.07014.79
5.3.160.0070.06314.63
5.3.150.0100.05014.54
5.3.140.0030.03714.59
5.3.130.0000.04014.61
5.3.120.0100.03014.61
5.3.110.0070.03314.78
5.3.100.0030.03714.09
5.3.90.0000.03713.89
5.3.80.0070.03014.04
5.3.70.0000.03714.09
5.3.60.0030.03313.91
5.3.50.0000.03714.00
5.3.40.0000.03714.02
5.3.30.0100.03014.03
5.3.20.0070.03013.81
5.3.10.0030.03313.57
5.3.00.0000.03713.71
5.2.170.0030.03011.05
5.2.160.0030.03711.22
5.2.150.0030.02711.38
5.2.140.0070.02311.08
5.2.130.0070.03011.19
5.2.120.0030.02711.02
5.2.110.0030.03011.34
5.2.100.0030.02711.12
5.2.90.0030.02711.33
5.2.80.0000.03011.17
5.2.70.0000.03311.12
5.2.60.0030.02711.17
5.2.50.0070.02311.08
5.2.40.0030.02711.23
5.2.30.0000.03011.03
5.2.20.0030.02711.05
5.2.10.0000.03010.83
5.2.00.0070.02310.59
5.1.60.0000.02310.06
5.1.50.0000.0239.99
5.1.40.0030.02310.06
5.1.30.0030.02310.25
5.1.20.0030.02310.41
5.1.10.0000.02710.17
5.1.00.0000.02710.08
5.0.50.0000.0208.57
5.0.40.0100.0238.53
5.0.30.0000.0678.27
5.0.20.0070.0338.27
5.0.10.0030.0478.27
5.0.00.0100.0478.27
4.4.90.0000.0138.27
4.4.80.0000.0138.27
4.4.70.0030.0138.27
4.4.60.0030.0138.27
4.4.50.0030.0138.27
4.4.40.0030.0238.27
4.4.30.0030.0138.27
4.4.20.0000.0138.27
4.4.10.0000.0138.27
4.4.00.0000.0308.27
4.3.110.0000.0278.27
4.3.100.0030.0338.27
4.3.90.0030.0338.27
4.3.80.0070.0408.27
4.3.70.0000.0238.27
4.3.60.0070.0278.27
4.3.50.0000.0238.27
4.3.40.0000.0338.27
4.3.30.0030.0178.27
4.3.20.0030.0378.27
4.3.10.0000.0408.27
4.3.00.0000.0278.27

preferences:
46.31 ms | 400 KiB | 5 Q