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() { return $this->__toString(); } public function __toString(){ $retval = array(); foreach ($this->policy as $directive => $sources) { if (sizeof($sources) > 0) { $retval[] = join(' ', array($directive, join(' ', $sources))); } } return 'Content-Security-Policy: ' . join('; ', $retval); } } class CSPException extends \Exception {} use ContentSecurityPolicy as CSP; $CSP = new CSP(); $CSP->addSource(CSP::DEFAULT_SRC, CSP::SOURCE_SELF) ->addSource(CSP::SCRIPT_SRC, CSP::SOURCE_SELF) ->addSource(CSP::SCRIPT_SRC, 'http://code.jquery.com') ->addSource(CSP::STYLE_SRC, ContentSecurityPolicy::SOURCE_SELF) ->addSource(CSP::STYLE_SRC, 'https://bootstrapcdn.com') ->addSource(CSP::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.0060.01518.68
8.3.50.0130.00521.92
8.3.40.0120.00619.01
8.3.30.0110.00420.17
8.3.20.0080.00018.76
8.3.10.0060.00321.22
8.3.00.0090.00023.70
8.2.180.0150.00316.50
8.2.170.0120.00322.96
8.2.160.0140.00020.43
8.2.150.0050.00324.18
8.2.140.0000.00724.66
8.2.130.0080.00026.16
8.2.120.0040.00419.89
8.2.110.0050.00519.27
8.2.100.0080.00418.16
8.2.90.0030.00519.21
8.2.80.0040.00419.19
8.2.70.0070.00717.84
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0080.00019.90
8.2.30.0030.00619.59
8.2.20.0040.00418.02
8.2.10.0040.00417.96
8.2.00.0030.00717.95
8.1.280.0160.00025.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00320.64
8.1.230.0090.00320.88
8.1.220.0000.00818.77
8.1.210.0040.00418.90
8.1.200.0000.01017.38
8.1.190.0060.00317.52
8.1.180.0060.00318.10
8.1.170.0030.00518.76
8.1.160.0050.00318.86
8.1.150.0000.01018.80
8.1.140.0000.00717.53
8.1.130.0030.00317.82
8.1.120.0020.00517.67
8.1.110.0060.00317.52
8.1.100.0060.00317.50
8.1.90.0020.00517.54
8.1.80.0000.00817.63
8.1.70.0040.00417.66
8.1.60.0040.00417.75
8.1.50.0030.00517.56
8.1.40.0030.00517.71
8.1.30.0080.00017.83
8.1.20.0050.00317.85
8.1.10.0080.00017.73
8.1.00.0030.00617.57
8.0.300.0000.00719.94
8.0.290.0070.00017.04
8.0.280.0000.00718.41
8.0.270.0000.00817.21
8.0.260.0030.00317.09
8.0.250.0050.00317.17
8.0.240.0040.00417.23
8.0.230.0040.00317.06
8.0.220.0070.00017.08
8.0.210.0000.00717.09
8.0.200.0030.00317.20
8.0.190.0000.00717.19
8.0.180.0040.00417.04
8.0.170.0040.00417.01
8.0.160.0040.00417.14
8.0.150.0000.00816.96
8.0.140.0040.00416.96
8.0.130.0060.00013.59
8.0.120.0000.00817.13
8.0.110.0040.00417.11
8.0.100.0040.00417.02
8.0.90.0000.00717.18
8.0.80.0090.00917.03
8.0.70.0050.00316.91
8.0.60.0040.00417.08
8.0.50.0050.00217.12
8.0.30.0130.00717.21
8.0.20.0130.00717.40
8.0.10.0000.00717.25
8.0.00.0150.00317.15
7.4.330.0030.00316.70
7.4.320.0030.00616.77
7.4.300.0030.00316.73
7.4.290.0030.00316.76
7.4.280.0080.00016.75
7.4.270.0070.00016.72
7.4.260.0000.00513.57
7.4.250.0050.00316.76
7.4.240.0030.00516.80
7.4.230.0030.00316.93
7.4.220.0070.01016.85
7.4.210.0070.00916.85
7.4.200.0000.00716.73
7.4.190.0040.00416.65
7.4.160.0110.00716.60
7.4.150.0130.00717.40
7.4.140.0060.01417.86
7.4.130.0030.01516.85
7.4.120.0100.01116.75
7.4.110.0150.00416.60
7.4.100.0070.01016.68
7.4.90.0090.01016.60
7.4.80.0140.00619.39
7.4.70.0140.01016.74
7.4.60.0080.00816.82
7.4.50.0030.00616.54
7.4.40.0030.00922.77
7.4.30.0040.01416.71
7.4.00.0000.01015.17
7.3.330.0050.00013.59
7.3.320.0050.00313.58
7.3.310.0000.00816.64
7.3.300.0070.00016.50
7.3.290.0150.00016.59
7.3.280.0070.01316.62
7.3.270.0140.00317.40
7.3.260.0090.00918.24
7.3.250.0130.00616.63
7.3.240.0100.00716.70
7.3.230.0130.00316.83
7.3.210.0120.00916.53
7.3.200.0190.00019.39
7.3.190.0130.00316.91
7.3.180.0150.00316.69
7.3.170.0110.01416.63
7.3.160.0100.01016.68
7.3.120.0040.01115.14
7.2.330.0080.01216.85
7.2.320.0150.00416.90
7.2.310.0170.00716.79
7.2.300.0030.01316.93
7.2.290.0060.01017.09
7.2.00.0060.00619.44
7.1.100.0000.01018.28
7.1.70.0030.00517.05
7.1.60.0090.01519.24
7.1.50.0100.01317.07
7.1.00.0070.04322.36
7.0.200.0000.00816.78
7.0.140.0070.07322.15
7.0.80.0170.05320.03
7.0.70.0030.04719.89
7.0.60.0100.07320.01
7.0.50.0070.08020.29
7.0.40.0130.07320.08
7.0.30.0070.08320.16
7.0.20.0030.09020.04
7.0.10.0130.06020.07
7.0.00.0070.08020.02
5.6.280.0000.07320.89
5.6.230.0100.07020.55
5.6.220.0070.04020.56
5.6.210.0100.06720.59
5.6.200.0130.05321.11
5.6.190.0030.05021.11
5.6.180.0200.07320.96
5.6.170.0070.08021.06
5.6.160.0030.09021.11
5.6.150.0100.08321.13
5.6.140.0170.07021.06
5.6.130.0100.08321.05
5.6.120.0070.08321.03
5.6.110.0070.06021.09
5.6.100.0130.05321.12
5.6.90.0200.06721.00
5.6.80.0130.07720.48
5.6.70.0130.06320.46
5.6.60.0070.07320.50
5.6.50.0130.07020.44
5.6.40.0100.07020.29
5.6.30.0100.05020.43
5.6.20.0130.07720.42
5.6.10.0100.06320.42
5.6.00.0070.08320.30
5.5.370.0100.08320.47
5.5.360.0100.07320.38
5.5.350.0030.07720.42
5.5.340.0070.05020.91
5.5.330.0100.07720.91
5.5.320.0000.06020.82
5.5.310.0130.05320.86
5.5.300.0070.08320.86
5.5.290.0100.07020.82
5.5.280.0070.04020.64
5.5.270.0100.07720.65
5.5.260.0200.07720.90
5.5.250.0100.03720.66
5.5.240.0030.08720.27
5.5.230.0070.08720.32
5.5.220.0070.08020.18
5.5.210.0070.07720.32
5.5.200.0100.06020.21
5.5.190.0170.07020.30
5.5.180.0130.08020.26
5.5.160.0100.05320.21
5.5.150.0130.07720.25
5.5.140.0130.07320.26
5.5.130.0070.08020.15
5.5.120.0030.05320.29
5.5.110.0130.07320.26
5.5.100.0070.07720.13
5.5.90.0100.07020.04
5.5.80.0070.07720.16
5.5.70.0100.07720.12
5.5.60.0130.04720.13
5.5.50.0130.07320.05
5.5.40.0070.07720.07
5.5.30.0100.07720.07
5.5.20.0100.07020.16
5.5.10.0170.06020.09
5.5.00.0100.06719.99
5.4.450.0070.07319.51
5.4.440.0070.06019.49
5.4.430.0030.08019.53
5.4.420.0070.04319.55
5.4.410.0030.06019.43
5.4.400.0170.04719.03
5.4.390.0070.07019.13
5.4.380.0170.07019.13
5.4.370.0130.07019.23
5.4.360.0000.08019.04
5.4.350.0100.07318.85
5.4.340.0030.05018.93
5.4.320.0070.07719.18
5.4.310.0070.07719.04
5.4.300.0070.07019.23
5.4.290.0100.07019.13
5.4.280.0130.06719.04
5.4.270.0100.07318.87
5.4.260.0100.07019.02
5.4.250.0130.04019.22
5.4.240.0070.07719.20
5.4.230.0030.06719.20
5.4.220.0070.06719.13
5.4.210.0030.07719.15
5.4.200.0070.06719.04
5.4.190.0070.06019.22
5.4.180.0030.05318.93
5.4.170.0130.06719.04
5.4.160.0100.04319.13
5.4.150.0070.07718.82
5.4.140.0030.06316.55
5.4.130.0030.04316.51
5.4.120.0070.03716.50
5.4.110.0100.06316.32
5.4.100.0130.06716.49
5.4.90.0100.05316.46
5.4.80.0030.05016.47
5.4.70.0070.06316.38
5.4.60.0100.07016.34
5.4.50.0100.07016.41
5.4.40.0070.07016.49
5.4.30.0100.06716.41
5.4.20.0070.07016.33
5.4.10.0030.06716.45
5.4.00.0070.06715.80
5.3.290.0000.06314.79
5.3.280.0070.06714.74
5.3.270.0170.04714.57
5.3.260.0030.07714.59
5.3.250.0030.07014.69
5.3.240.0070.05014.65
5.3.230.0030.04314.55
5.3.220.0130.07014.65
5.3.210.0100.06714.59
5.3.200.0030.05314.66
5.3.190.0100.07014.71
5.3.180.0030.07314.57
5.3.170.0070.07714.64
5.3.160.0130.06014.70
5.3.150.0100.07314.73
5.3.140.0000.06314.57
5.3.130.0070.07714.54
5.3.120.0030.07714.63
5.3.110.0070.07314.55
5.3.100.0000.04313.99
5.3.90.0070.06313.99
5.3.80.0070.05014.14
5.3.70.0100.07314.09
5.3.60.0070.07014.09
5.3.50.0030.07714.03
5.3.40.0030.05014.11
5.3.30.0100.04313.82
5.3.20.0030.06713.85
5.3.10.0000.08013.80
5.3.00.0030.07713.68
5.2.170.0030.04311.89
5.2.160.0030.04711.89
5.2.150.0100.04311.89
5.2.140.0130.05711.89
5.2.130.0030.06011.89
5.2.120.0200.04311.89
5.2.110.0070.06011.89
5.2.100.0030.05311.89
5.2.90.0030.06011.89
5.2.80.0030.06011.89
5.2.70.0070.05311.89
5.2.60.0070.06011.89
5.2.50.0000.06711.89
5.2.40.0030.05011.89
5.2.30.0000.04311.89
5.2.20.0070.05711.89
5.2.10.0000.06711.89
5.2.00.0070.05711.89
5.1.60.0070.04311.89
5.1.50.0070.05011.89
5.1.40.0030.05311.89
5.1.30.0030.05311.89
5.1.20.0030.05711.89
5.1.10.0130.04711.89
5.1.00.0000.06011.89
5.0.50.0030.04011.89
5.0.40.0030.03311.89
5.0.30.0070.06311.89
5.0.20.0000.03311.89
5.0.10.0070.03711.89
5.0.00.0000.06011.89
4.4.90.0030.03311.89
4.4.80.0000.03711.89
4.4.70.0000.03311.89
4.4.60.0070.02011.89
4.4.50.0030.02011.89
4.4.40.0000.06011.89
4.4.30.0030.03311.89
4.4.20.0000.02711.89
4.4.10.0030.03711.89
4.4.00.0030.05011.89
4.3.110.0030.03311.89
4.3.100.0000.03711.89
4.3.90.0000.03711.89
4.3.80.0000.05311.89
4.3.70.0030.03011.89
4.3.60.0000.03711.89
4.3.50.0030.02711.89
4.3.40.0000.04711.89
4.3.30.0000.03711.89
4.3.20.0030.03011.89
4.3.10.0000.03711.89
4.3.00.0000.03311.89

preferences:
49.47 ms | 401 KiB | 5 Q