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 (preg_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.0080.00818.80
8.3.50.0100.00821.21
8.3.40.0120.00319.22
8.3.30.0150.00020.32
8.3.20.0040.00420.24
8.3.10.0030.00521.97
8.3.00.0030.00622.57
8.2.180.0130.00716.72
8.2.170.0040.01122.96
8.2.160.0070.00722.30
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.02
8.2.110.0040.00421.12
8.2.100.0080.00418.09
8.2.90.0030.00518.16
8.2.80.0000.00917.97
8.2.70.0030.00518.05
8.2.60.0000.00918.09
8.2.50.0060.00318.10
8.2.40.0050.00318.34
8.2.30.0000.00719.49
8.2.20.0080.00018.04
8.2.10.0000.00817.88
8.2.00.0080.00017.98
8.1.280.0140.00725.92
8.1.270.0090.00023.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0050.00523.84
8.1.230.0080.00422.66
8.1.220.0000.00817.91
8.1.210.0000.00818.77
8.1.200.0030.00717.60
8.1.190.0000.00917.61
8.1.180.0040.00418.10
8.1.170.0050.00318.82
8.1.160.0060.00318.87
8.1.150.0040.00418.87
8.1.140.0000.00717.55
8.1.130.0030.00317.96
8.1.120.0070.00017.67
8.1.110.0040.00417.68
8.1.100.0000.00817.65
8.1.90.0000.00717.64
8.1.80.0040.00417.53
8.1.70.0030.00317.61
8.1.60.0030.00517.71
8.1.50.0030.00617.75
8.1.40.0040.00717.66
8.1.30.0000.00817.70
8.1.20.0030.00617.83
8.1.10.0030.00517.63
8.1.00.0030.00617.58
8.0.300.0040.00421.72
8.0.290.0060.00317.13
8.0.280.0070.00018.42
8.0.270.0040.00417.27
8.0.260.0030.00316.99
8.0.250.0030.00317.23
8.0.240.0110.00017.21
8.0.230.0040.00417.14
8.0.220.0070.00017.09
8.0.210.0070.00017.05
8.0.200.0040.00417.18
8.0.190.0050.00217.21
8.0.180.0080.00017.22
8.0.170.0040.00417.15
8.0.160.0040.00417.10
8.0.150.0070.00016.98
8.0.140.0040.00417.06
8.0.130.0030.00313.54
8.0.120.0040.00417.11
8.0.110.0040.00417.13
8.0.100.0030.00517.13
8.0.90.0000.00817.13
8.0.80.0090.00917.21
8.0.70.0000.00717.12
8.0.60.0000.00817.05
8.0.50.0020.00517.26
8.0.30.0120.00817.32
8.0.20.0100.00917.48
8.0.10.0020.00517.29
8.0.00.0100.00917.22
7.4.330.0060.00016.86
7.4.320.0000.00716.75
7.4.300.0030.00316.87
7.4.290.0040.00416.67
7.4.280.0000.00816.66
7.4.270.0030.00316.62
7.4.260.0050.00013.52
7.4.250.0040.00416.78
7.4.240.0010.00716.78
7.4.230.0040.00416.98
7.4.220.0040.01616.77
7.4.210.0050.00916.83
7.4.200.0040.00416.69
7.4.190.0030.00516.95
7.4.160.0180.00416.75
7.4.150.0070.01017.40
7.4.140.0060.01117.86
7.4.130.0100.00816.83
7.4.120.0100.00916.71
7.4.110.0080.00816.59
7.4.100.0100.00616.93
7.4.90.0030.01416.95
7.4.80.0030.01919.39
7.4.70.0120.00616.74
7.4.60.0090.00916.82
7.4.50.0000.00816.60
7.4.40.0090.00622.77
7.4.30.0140.00616.65
7.4.00.0030.01015.30
7.3.330.0030.00313.66
7.3.320.0000.00513.48
7.3.310.0000.00816.75
7.3.300.0070.00016.64
7.3.290.0050.00916.64
7.3.280.0090.00916.64
7.3.270.0090.00917.40
7.3.260.0040.01418.24
7.3.250.0090.00816.85
7.3.240.0110.00616.62
7.3.230.0160.00716.70
7.3.210.0070.01116.77
7.3.200.0030.01519.39
7.3.190.0120.01216.82
7.3.180.0030.01316.82
7.3.170.0060.01016.66
7.3.160.0090.00916.70
7.3.120.0100.00615.38
7.3.10.0160.01216.44
7.3.00.0120.00916.66
7.2.330.0100.01017.05
7.2.320.0000.01816.70
7.2.310.0180.00417.04
7.2.300.0090.00916.88
7.2.290.0140.00916.88
7.2.130.0200.00916.61
7.2.120.0080.00816.79
7.2.110.0180.00716.77
7.2.100.0190.00417.16
7.2.90.0250.00316.98
7.2.80.0050.01016.95
7.2.70.0130.00417.01
7.2.60.0100.01216.93
7.2.50.0030.01016.88
7.2.40.0090.00617.01
7.2.30.0190.00316.93
7.2.20.0100.00616.95
7.2.10.0030.01317.02
7.2.00.0070.00718.12
7.1.250.0280.00815.78
7.1.200.0070.00716.04
7.1.100.0060.01218.47
7.1.70.0000.00817.11
7.1.60.0070.01619.17
7.1.50.0240.00617.16
7.1.00.0030.05022.38
7.0.200.0000.01616.66
7.0.140.0030.07022.21
7.0.100.0130.07719.89
7.0.90.0030.07319.95
7.0.80.0130.07719.99
7.0.70.0100.08020.06
7.0.60.0070.08019.96
7.0.50.0070.07322.19
7.0.40.0030.08020.05
7.0.30.0100.08320.08
7.0.20.0100.08020.04
7.0.10.0030.08720.04
7.0.00.0070.08020.03
5.6.280.0070.07021.06
5.6.250.0070.04320.66
5.6.240.0070.08320.72
5.6.230.0030.08320.69
5.6.220.0170.04720.52
5.6.210.0230.06720.61
5.6.200.0100.08320.99
5.6.190.0030.08321.11
5.6.180.0100.08021.08
5.6.170.0070.08021.06
5.6.160.0100.08021.06
5.6.150.0030.06021.05
5.6.140.0000.08021.04
5.6.130.0030.08721.05
5.6.120.0030.08321.09
5.6.110.0030.08021.06
5.6.100.0100.07721.20
5.6.90.0170.08021.14
5.6.80.0100.07320.49
5.6.70.0100.07020.41
5.6.60.0100.05020.40
5.6.50.0030.08020.53
5.6.40.0170.07020.34
5.6.30.0030.07720.41
5.6.20.0000.08320.41
5.6.10.0100.06720.39
5.6.00.0070.07720.30
5.5.380.0130.07020.60
5.5.370.0100.07720.44
5.5.360.0000.08320.36
5.5.350.0230.07020.49
5.5.340.0000.09320.83
5.5.330.0130.07720.83
5.5.320.0170.04720.79
5.5.310.0030.08020.76
5.5.300.0070.08320.90
5.5.290.0100.08720.89
5.5.280.0030.07320.80
5.5.270.0000.04720.82
5.5.260.0070.08320.91
5.5.250.0130.05020.71
5.5.240.0070.06320.34
5.5.230.0070.07320.17
5.5.220.0100.07720.24
5.5.210.0070.07320.14
5.5.200.0130.07020.28
5.5.190.0070.08020.16
5.5.180.0100.08020.13
5.5.160.0070.03719.99
5.5.150.0130.08020.31
5.5.140.0100.07020.15
5.5.130.0030.05320.27
5.5.120.0070.07720.21
5.5.110.0070.07720.25
5.5.100.0030.06720.10
5.5.90.0070.07720.07
5.5.80.0100.07320.19
5.5.70.0030.08320.11
5.5.60.0100.07720.05
5.5.50.0070.05020.09
5.5.40.0070.07720.04
5.5.30.0030.05719.95
5.5.20.0100.07320.11
5.5.10.0000.07720.13
5.5.00.0000.05320.05
5.4.450.0200.06319.42
5.4.440.0000.05019.37
5.4.430.0100.07719.50
5.4.420.0070.07719.54
5.4.410.0070.07719.41
5.4.400.0030.07719.10
5.4.390.0030.07718.86
5.4.380.0130.07019.23
5.4.370.0030.08019.05
5.4.360.0100.07319.09
5.4.350.0100.07318.85
5.4.340.0000.07719.05
5.4.320.0130.05719.19
5.4.310.0030.04018.88
5.4.300.0070.07719.16
5.4.290.0000.08018.90
5.4.280.0070.06319.18
5.4.270.0130.06318.88
5.4.260.0100.07319.14
5.4.250.0030.05719.23
5.4.240.0070.04319.13
5.4.230.0030.05318.89
5.4.220.0100.07719.20
5.4.210.0070.07718.89
5.4.200.0000.07718.90
5.4.190.0070.07319.08
5.4.180.0100.07019.09
5.4.170.0070.07718.87
5.4.160.0030.07718.86
5.4.150.0130.04318.84
5.4.140.0100.07316.51
5.4.130.0100.06316.48
5.4.120.0070.07716.47
5.4.110.0170.07016.49
5.4.100.0000.08016.33
5.4.90.0070.07016.45
5.4.80.0030.08316.38
5.4.70.0030.07316.55
5.4.60.0030.07716.49
5.4.50.0170.06316.31
5.4.40.0070.07716.52
5.4.30.0070.07716.47
5.4.20.0030.08316.42
5.4.10.0170.06016.33
5.4.00.0170.07015.82
5.3.290.0100.04314.76
5.3.280.0000.08014.69
5.3.270.0100.06014.67
5.3.260.0070.04314.59
5.3.250.0170.04714.62
5.3.240.0100.07014.66
5.3.230.0100.07314.70
5.3.220.0130.06714.60
5.3.210.0030.07314.66
5.3.200.0030.07314.55
5.3.190.0000.06014.66
5.3.180.0000.06714.66
5.3.170.0070.07714.69
5.3.160.0100.07714.70
5.3.150.0070.07714.60
5.3.140.0030.08014.72
5.3.130.0030.08314.67
5.3.120.0070.07714.51
5.3.110.0030.08014.63
5.3.100.0030.07714.20
5.3.90.0070.06714.10
5.3.80.0100.07013.98
5.3.70.0130.05013.97
5.3.60.0000.05714.05
5.3.50.0130.07014.04
5.3.40.0030.07714.04
5.3.30.0070.08013.89
5.3.20.0200.05713.61
5.3.10.0070.07013.71
5.3.00.0030.07713.76
5.2.170.0070.06011.33
5.2.160.0070.05711.27
5.2.150.0070.06311.29
5.2.140.0070.06311.27
5.2.130.0030.06711.19
5.2.120.0030.06311.05
5.2.110.0070.06011.23
5.2.100.0070.04011.16
5.2.90.0000.06711.18
5.2.80.0000.06711.21
5.2.70.0200.05011.15
5.2.60.0000.04310.98
5.2.50.0070.07011.05
5.2.40.0100.05010.92
5.2.30.0100.03311.13
5.2.20.0070.06310.90
5.2.10.0030.06310.82
5.2.00.0000.06710.84
5.1.60.0070.05310.10
5.1.50.0030.05010.10
5.1.40.0000.06010.07
5.1.30.0100.04710.32
5.1.20.0030.04310.32
5.1.10.0030.03710.10
5.1.00.0030.04010.20
5.0.50.0000.0208.69
5.0.40.0000.0238.29
5.0.30.0000.0478.28
5.0.20.0030.0278.36
5.0.10.0000.0208.28
5.0.00.0000.0308.28
4.4.90.0030.0408.28
4.4.80.0030.0338.28
4.4.70.0030.0378.28
4.4.60.0030.0338.28
4.4.50.0000.0378.28
4.4.40.0000.0608.28
4.4.30.0000.0438.28
4.4.20.0030.0338.28
4.4.10.0000.0308.28
4.4.00.0000.0308.28
4.3.110.0000.0308.28
4.3.100.0000.0178.28
4.3.90.0000.0178.28
4.3.80.0030.0238.28
4.3.70.0000.0308.28
4.3.60.0030.0238.28
4.3.50.0000.0238.28
4.3.40.0030.0278.28
4.3.30.0030.0208.28
4.3.20.0000.0308.28
4.3.10.0070.0108.28
4.3.00.0030.0178.28

preferences:
51.38 ms | 401 KiB | 5 Q