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.0030.01218.48
8.3.50.0120.00821.27
8.3.40.0110.00719.27
8.3.30.0070.00720.25
8.3.20.0030.00620.29
8.3.10.0110.00422.08
8.3.00.0030.00622.52
8.2.180.0070.01118.66
8.2.170.0030.01222.96
8.2.160.0070.00722.33
8.2.150.0060.00324.18
8.2.140.0000.00924.66
8.2.130.0040.00726.16
8.2.120.0000.00820.79
8.2.110.0000.00922.02
8.2.100.0030.00918.03
8.2.90.0040.00419.03
8.2.80.0040.00419.35
8.2.70.0030.00517.74
8.2.60.0030.00518.05
8.2.50.0000.00818.07
8.2.40.0030.00518.34
8.2.30.0000.00719.38
8.2.20.0040.00417.96
8.2.10.0000.00818.07
8.2.00.0060.00318.06
8.1.280.0090.00625.92
8.1.270.0050.00523.99
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0060.00920.84
8.1.230.0070.00417.95
8.1.220.0040.00417.74
8.1.210.0100.00318.77
8.1.200.0000.00917.38
8.1.190.0040.00417.54
8.1.180.0080.00018.10
8.1.170.0060.00318.78
8.1.160.0070.00418.79
8.1.150.0030.00618.80
8.1.140.0030.00517.65
8.1.130.0030.00317.74
8.1.120.0020.00517.63
8.1.110.0000.00717.56
8.1.100.0050.00317.62
8.1.90.0040.00417.69
8.1.80.0000.00717.53
8.1.70.0030.00317.52
8.1.60.0040.00417.80
8.1.50.0040.00417.58
8.1.40.0000.00917.66
8.1.30.0080.00017.79
8.1.20.0030.00617.82
8.1.10.0030.00517.70
8.1.00.0000.00817.71
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0000.00718.41
8.0.270.0050.00217.21
8.0.260.0040.00417.04
8.0.250.0050.00217.06
8.0.240.0000.00817.07
8.0.230.0040.00417.06
8.0.220.0070.00017.12
8.0.210.0040.00417.14
8.0.200.0030.00317.18
8.0.190.0000.00817.18
8.0.180.0000.00717.13
8.0.170.0070.00017.04
8.0.160.0000.00717.06
8.0.150.0000.00717.09
8.0.140.0040.00716.97
8.0.130.0030.00313.50
8.0.120.0000.01017.19
8.0.110.0000.00716.95
8.0.100.0080.00017.16
8.0.90.0050.00317.01
8.0.80.0000.02217.14
8.0.70.0040.00417.00
8.0.60.0040.00416.98
8.0.50.0040.00417.14
8.0.30.0170.00317.35
8.0.20.0100.00817.41
8.0.10.0040.00417.13
8.0.00.0130.00516.99
7.4.330.0030.00316.85
7.4.320.0000.00716.86
7.4.300.0030.00316.64
7.4.290.0030.00316.69
7.4.280.0040.00416.85
7.4.270.0000.00716.86
7.4.260.0000.00513.55
7.4.250.0070.00016.62
7.4.240.0020.00516.79
7.4.230.0030.00316.64
7.4.220.0070.01116.88
7.4.210.0050.01016.79
7.4.200.0070.00016.66
7.4.190.0040.00416.81
7.4.160.0080.00816.71
7.4.150.0140.00317.40
7.4.140.0090.00917.86
7.4.130.0080.01116.83
7.4.120.0100.00816.71
7.4.110.0060.01316.61
7.4.100.0000.01816.93
7.4.90.0110.00516.77
7.4.80.0100.00719.39
7.4.70.0100.00716.82
7.4.60.0100.00716.64
7.4.50.0040.00416.84
7.4.40.0000.01622.77
7.4.30.0110.00616.96
7.4.10.0090.00915.41
7.4.00.0090.00915.17
7.3.330.0050.00013.57
7.3.320.0050.00013.48
7.3.310.0000.00816.53
7.3.300.0030.00316.50
7.3.290.0040.01116.66
7.3.280.0070.01016.66
7.3.270.0030.01317.40
7.3.260.0120.00618.24
7.3.250.0120.00816.81
7.3.240.0110.01116.77
7.3.230.0150.00616.65
7.3.210.0070.01016.66
7.3.200.0140.00319.39
7.3.190.0060.01116.64
7.3.180.0110.00616.54
7.3.170.0100.01316.64
7.3.160.0140.00316.82
7.3.130.0140.00415.28
7.3.120.0070.00915.08
7.3.110.0070.01015.30
7.3.100.0070.01015.30
7.3.90.0070.01015.21
7.3.80.0000.00915.02
7.3.70.0030.01014.77
7.3.60.0030.01015.16
7.3.50.0100.00714.97
7.3.40.0100.00715.18
7.3.30.0140.00715.14
7.3.20.0070.00716.74
7.3.10.0030.01016.94
7.3.00.0110.00617.08
7.2.330.0100.00717.02
7.2.320.0100.00617.01
7.2.310.0090.00916.93
7.2.300.0030.01316.89
7.2.290.0060.01116.82
7.2.260.0030.01315.27
7.2.250.0140.00715.41
7.2.240.0000.01315.15
7.2.230.0100.00315.11
7.2.220.0070.01015.41
7.2.210.0070.00315.48
7.2.200.0060.00915.29
7.2.190.0000.01215.32
7.2.180.0000.01415.28
7.2.170.0080.00815.13
7.2.160.0070.01315.25
7.2.150.0030.00917.36
7.2.140.0040.00817.10
7.2.130.0070.00717.08
7.2.120.0030.00617.21
7.2.110.0040.00717.14
7.2.100.0000.01217.18
7.2.90.0090.00616.88
7.2.80.0030.00617.29
7.2.70.0000.01517.17
7.2.60.0030.01217.29
7.2.50.0030.01017.21
7.2.40.0000.01216.89
7.2.30.0000.01417.20
7.2.20.0000.00917.18
7.2.10.0110.00317.16
7.2.00.0050.00818.17
7.1.330.0040.00715.84
7.1.320.0090.00915.92
7.1.310.0080.00615.83
7.1.300.0060.00915.69
7.1.290.0000.00816.00
7.1.280.0070.01115.96
7.1.270.0030.01516.14
7.1.260.0030.00715.93
7.1.250.0080.00416.11
7.1.240.0030.00716.02
7.1.230.0060.00615.97
7.1.220.0080.00016.05
7.1.210.0070.00715.99
7.1.200.0050.00615.95
7.1.190.0030.00915.98
7.1.180.0000.00915.97
7.1.170.0030.00615.82
7.1.160.0060.00615.89
7.1.150.0040.00816.10
7.1.140.0000.00915.96
7.1.130.0090.00315.88
7.1.120.0030.01016.08
7.1.110.0040.00416.19
7.1.100.0060.00517.13
7.1.90.0030.00915.82
7.1.80.0030.00615.70
7.1.70.0020.00916.69
7.1.60.0090.00817.55
7.1.50.0060.01116.62
7.1.40.0070.00716.09
7.1.30.0000.01615.64
7.1.20.0030.00615.95
7.1.10.0000.01615.94
7.1.00.0030.04019.22
7.0.330.0030.01015.70
7.0.320.0030.01015.75
7.0.310.0030.00615.61
7.0.300.0030.01015.39
7.0.290.0110.00315.55
7.0.280.0030.01015.30
7.0.270.0000.00815.63
7.0.260.0050.00315.38
7.0.250.0000.01415.54
7.0.240.0040.00915.75
7.0.230.0080.00415.68
7.0.220.0030.00915.61
7.0.210.0070.00415.74
7.0.200.0040.00416.41
7.0.190.0060.00315.21
7.0.180.0070.00715.56
7.0.170.0070.00715.39
7.0.160.0040.00415.45
7.0.150.0070.01015.72
7.0.140.0050.04318.83
7.0.130.0100.00715.54
7.0.120.0060.00315.48
7.0.110.0030.00915.65
7.0.100.0280.03217.79
7.0.90.0230.04317.64
7.0.80.0220.04117.99
7.0.70.0220.02217.81
7.0.60.0070.02917.94
7.0.50.0050.02718.07
7.0.40.0050.02016.90
7.0.30.0030.02516.82
7.0.20.0020.04416.87
7.0.10.0050.03916.88
7.0.00.0070.03716.72
5.6.400.0090.00614.72
5.6.390.0030.01014.94
5.6.380.0060.00914.48
5.6.370.0100.00014.81
5.6.360.0040.00814.62
5.6.350.0000.00814.76
5.6.340.0030.00614.73
5.6.330.0080.00414.96
5.6.320.0060.00614.83
5.6.310.0110.00714.76
5.6.300.0000.01514.75
5.6.290.0000.01314.78
5.6.280.0030.00914.44
5.6.270.0040.00714.91
5.6.260.0100.00614.70
5.6.250.0050.04317.55
5.6.240.0050.04617.67
5.6.230.0130.04217.59
5.6.220.0070.02417.52
5.6.210.0020.02817.65
5.6.200.0030.02717.84
5.6.190.0030.02917.81
5.6.180.0070.02417.88
5.6.170.0000.03617.90
5.6.160.0030.04717.76
5.6.150.0060.03517.85
5.6.140.0060.02217.83
5.6.130.0090.02917.73
5.6.120.0070.02317.80
5.6.110.0050.03217.84
5.6.100.0050.03217.72
5.6.90.0050.02317.82
5.6.80.0070.02317.50
5.6.70.0030.02217.51
5.6.60.0050.02317.61
5.6.50.0100.02217.44
5.6.40.0030.03517.58
5.6.30.0060.02317.61
5.6.20.0050.02717.37
5.6.10.0010.02317.43
5.6.00.0030.02917.45
5.5.380.0050.05117.49
5.5.370.0090.04117.67
5.5.360.0120.02317.59
5.5.350.0050.02517.54
5.5.340.0100.03517.52
5.5.330.0080.02017.61
5.5.320.0030.03117.55
5.5.310.0080.04317.71
5.5.300.0060.02517.62
5.5.290.0080.02417.67
5.5.280.0060.03817.74
5.5.270.0050.04517.62
5.5.260.0020.02917.72
5.5.250.0050.02517.47
5.5.240.0100.01817.45
5.5.230.0030.02317.35
5.5.220.0030.02817.39
5.5.210.0080.02117.38
5.5.200.0090.01917.42
5.5.190.0050.02217.39
5.5.180.0030.02717.38
5.5.170.0060.00814.49
5.5.160.0050.02317.26
5.5.150.0080.02217.36
5.5.140.0130.02517.35
5.5.130.0110.03617.43
5.5.120.0070.03917.40
5.5.110.0080.03517.30
5.5.100.0090.04117.23
5.5.90.0130.03817.23
5.5.80.0040.04617.34
5.5.70.0100.03917.28
5.5.60.0040.02817.32
5.5.50.0070.04617.22
5.5.40.0100.03317.25
5.5.30.0050.04117.22
5.5.20.0050.04217.33
5.5.10.0030.03817.25
5.5.00.0040.04117.27
5.4.450.0040.02415.44
5.4.440.0050.03715.44
5.4.430.0040.02415.42
5.4.420.0050.02215.36
5.4.410.0030.02215.47
5.4.400.0000.02615.29
5.4.390.0090.01715.29
5.4.380.0050.02115.30
5.4.370.0070.01815.37
5.4.360.0060.02315.20
5.4.350.0060.01815.19
5.4.340.0020.02215.28
5.4.330.0000.00611.50
5.4.320.0070.02415.27
5.4.310.0060.02315.32
5.4.300.0030.02415.29
5.4.290.0050.01915.22
5.4.280.0050.04115.19
5.4.270.0020.02515.27
5.4.260.0080.03815.33
5.4.250.0050.04415.27
5.4.240.0030.04115.29
5.4.230.0130.03315.36
5.4.220.0070.04215.35
5.4.210.0050.04015.37
5.4.200.0120.03715.32
5.4.190.0080.03915.26
5.4.180.0130.03215.36
5.4.170.0120.03215.18
5.4.160.0030.03815.18
5.4.150.0030.04515.30
5.4.140.0000.04713.87
5.4.130.0020.04213.94
5.4.120.0030.04113.90
5.4.110.0100.03714.03
5.4.100.0050.04313.99
5.4.90.0060.04113.97
5.4.80.0070.02714.01
5.4.70.0060.03813.97
5.4.60.0050.03213.99
5.4.50.0050.03313.97
5.4.40.0130.03113.96
5.4.30.0050.03013.91
5.4.20.0080.03313.98
5.4.10.0080.04013.98
5.4.00.0060.03513.69
5.3.290.0070.01813.09
5.3.280.0050.03813.04
5.3.270.0100.03313.06
5.3.260.0070.03913.11
5.3.250.0060.03313.11
5.3.240.0040.04113.14
5.3.230.0090.03713.13
5.3.220.0050.03713.08
5.3.210.0030.03813.12
5.3.200.0020.04513.01
5.3.190.0060.03913.10
5.3.180.0050.03813.11
5.3.170.0070.03813.12
5.3.160.0050.02713.02
5.3.150.0030.04313.04
5.3.140.0050.04413.03
5.3.130.0060.03813.04
5.3.120.0050.04013.03
5.3.110.0050.03913.02
5.3.100.0000.03812.76
5.3.90.0070.03512.83
5.3.80.0000.04312.80
5.3.70.0090.03712.83
5.3.60.0020.05012.81
5.3.50.0050.02912.73
5.3.40.0070.03712.75
5.3.30.0030.03512.75
5.3.20.0090.03312.62
5.3.10.0080.03612.56
5.3.00.0020.03512.64
5.2.170.0030.06311.27
5.2.160.0000.06011.23
5.2.150.0130.05711.19
5.2.140.0130.05311.27
5.2.130.0070.06011.06
5.2.120.0100.06011.27
5.2.110.0070.06711.02
5.2.100.0030.06011.03
5.2.90.0100.06011.04
5.2.80.0070.06011.10
5.2.70.0000.04011.14
5.2.60.0000.06311.20
5.2.50.0070.06010.94
5.2.40.0030.06011.14
5.2.30.0030.06711.09
5.2.20.0070.05011.08
5.2.10.0030.06010.89
5.2.00.0030.06710.86
5.1.60.0070.05310.15
5.1.50.0070.05310.03
5.1.40.0070.0509.89
5.1.30.0030.06010.32
5.1.20.0100.05010.44
5.1.10.0070.06010.13
5.1.00.0000.03710.22
5.0.50.0000.0509.61
5.0.40.0030.0279.61
5.0.30.0100.0609.61
5.0.20.0030.0309.61
5.0.10.0030.0239.61
5.0.00.0070.0709.61
4.4.90.0000.0179.61
4.4.80.0000.0279.61
4.4.70.0030.0379.61
4.4.60.0000.0309.61
4.4.50.0070.0239.61
4.4.40.0070.0509.61
4.4.30.0030.0379.61
4.4.20.0000.0379.61
4.4.10.0030.0309.61
4.4.00.0070.0539.61
4.3.110.0000.0339.61
4.3.100.0000.0379.61
4.3.90.0070.0279.61
4.3.80.0000.0539.61
4.3.70.0000.0379.61
4.3.60.0030.0339.61
4.3.50.0030.0339.61
4.3.40.0030.0539.61
4.3.30.0030.0339.61
4.3.20.0100.0309.61
4.3.10.0030.0379.61
4.3.00.0000.0379.61

preferences:
47.75 ms | 401 KiB | 5 Q