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 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.60.0170.00318.68
8.3.50.0090.01121.21
8.3.40.0040.01119.14
8.3.30.0000.01420.35
8.3.20.0070.00020.25
8.3.10.0090.00621.97
8.3.00.0000.00822.51
8.2.180.0070.01116.88
8.2.170.0090.00622.96
8.2.160.0070.00722.09
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0080.00020.78
8.2.110.0040.00722.41
8.2.100.0050.00519.95
8.2.90.0040.00419.30
8.2.80.0050.00319.46
8.2.70.0060.00318.00
8.2.60.0040.00417.93
8.2.50.0060.00318.07
8.2.40.0050.00318.34
8.2.30.0070.00019.36
8.2.20.0030.00517.89
8.2.10.0000.00817.96
8.2.00.0080.00018.07
8.1.280.0030.01425.92
8.1.270.0060.00323.99
8.1.260.0030.00526.35
8.1.250.0070.00028.09
8.1.240.0030.00723.91
8.1.230.0060.00619.11
8.1.220.0000.00817.78
8.1.210.0050.00318.77
8.1.200.0040.00417.35
8.1.190.0000.00817.66
8.1.180.0040.00418.10
8.1.170.0040.00418.61
8.1.160.0030.00918.89
8.1.150.0070.00018.68
8.1.140.0040.00417.68
8.1.130.0000.00817.79
8.1.120.0000.00717.60
8.1.110.0030.00517.58
8.1.100.0000.00717.48
8.1.90.0000.00717.72
8.1.80.0000.00717.53
8.1.70.0070.00017.61
8.1.60.0080.00017.64
8.1.50.0050.00317.59
8.1.40.0060.00517.66
8.1.30.0080.00017.73
8.1.20.0000.00817.77
8.1.10.0000.00817.66
8.1.00.0000.00717.67
8.0.300.0030.00618.77
8.0.290.0070.00017.18
8.0.280.0000.00718.40
8.0.270.0000.00717.36
8.0.260.0030.00616.95
8.0.250.0000.00717.22
8.0.240.0000.00817.03
8.0.230.0030.00317.06
8.0.220.0030.00517.02
8.0.210.0000.00817.02
8.0.200.0000.00817.18
8.0.190.0060.00317.02
8.0.180.0040.00417.14
8.0.170.0070.00017.19
8.0.160.0000.00716.99
8.0.150.0000.00716.96
8.0.140.0030.00716.97
8.0.130.0050.00213.54
8.0.120.0080.00017.09
8.0.110.0050.00317.09
8.0.100.0040.00416.94
8.0.90.0070.00017.14
8.0.80.0090.00617.14
8.0.70.0000.00817.12
8.0.60.0040.00417.10
8.0.50.0040.00417.06
8.0.30.0060.01417.44
8.0.20.0090.01017.46
8.0.10.0040.00417.23
8.0.00.0130.00616.90
7.4.330.0020.00216.77
7.4.320.0030.00316.74
7.4.300.0000.00616.75
7.4.290.0000.00716.67
7.4.280.0070.00016.88
7.4.270.0000.00716.65
7.4.260.0000.00513.55
7.4.250.0040.00416.70
7.4.240.0020.00516.70
7.4.230.0000.00816.83
7.4.220.0100.01016.82
7.4.210.0080.00716.82
7.4.200.0000.00816.86
7.4.190.0050.00216.99
7.4.160.0170.00616.72
7.4.150.0070.01017.40
7.4.140.0090.00917.86
7.4.130.0060.01116.69
7.4.120.0050.01216.63
7.4.110.0030.01316.77
7.4.100.0090.01016.68
7.4.90.0060.01216.94
7.4.80.0120.00819.39
7.4.70.0110.00616.80
7.4.60.0090.00916.71
7.4.50.0060.00316.67
7.4.40.0020.00822.77
7.4.30.0110.00716.64
7.4.00.0090.00615.10
7.3.330.0030.00313.64
7.3.320.0030.00313.56
7.3.310.0000.00816.63
7.3.300.0040.00416.62
7.3.290.0030.01116.62
7.3.280.0070.01016.65
7.3.270.0070.01117.40
7.3.260.0130.00618.24
7.3.250.0090.00916.88
7.3.240.0130.00616.86
7.3.230.0130.01016.59
7.3.210.0070.01016.78
7.3.200.0090.00919.39
7.3.190.0160.00716.71
7.3.180.0090.00616.54
7.3.170.0060.00916.68
7.3.160.0070.01016.76
7.3.120.0070.00714.98
7.2.330.0060.01216.92
7.2.320.0100.00717.02
7.2.310.0030.01316.97
7.2.300.0110.00716.82
7.2.290.0090.00916.73
7.2.60.0080.00017.32
7.1.200.0080.00415.92
7.1.100.0060.00918.34
7.1.70.0030.00617.42
7.1.60.0140.01119.17
7.1.50.0180.00717.05
7.1.00.0030.05322.37
7.0.200.0040.00414.88
7.0.140.0070.07021.95
7.0.110.0030.04720.13
7.0.100.0030.09020.01
7.0.90.0130.09019.97
7.0.80.0230.05719.99
7.0.70.0070.04720.02
7.0.60.0100.07319.94
7.0.50.0100.07320.00
7.0.40.0130.07719.82
7.0.30.0000.09019.65
7.0.20.0200.06719.77
7.0.10.0100.08319.68
7.0.00.0030.06019.87
5.6.280.0000.07721.06
5.6.260.0030.08020.74
5.6.250.0130.07320.62
5.6.240.0030.05320.71
5.6.230.0130.07320.66
5.6.220.0100.05720.72
5.6.210.0230.07320.71
5.6.200.0070.06720.88
5.6.190.0070.06320.61
5.6.180.0030.07020.66
5.6.170.0030.08720.72
5.6.160.0070.08320.65
5.6.150.0030.05020.66
5.6.140.0070.08320.71
5.6.130.0130.07720.88
5.6.120.0130.08020.62
5.6.110.0070.08020.64
5.6.100.0100.08020.71
5.6.90.0030.09020.86
5.6.80.0070.04719.95
5.6.70.0070.07719.86
5.6.60.0000.08020.20
5.6.50.0000.04319.87
5.6.40.0030.05019.85
5.6.30.0100.06720.02
5.6.20.0000.06320.08
5.6.10.0030.06720.08
5.6.00.0070.03719.93
5.5.380.0100.04317.70
5.5.370.0170.07017.70
5.5.360.0130.07717.52
5.5.350.0070.07317.66
5.5.340.0000.06018.27
5.5.330.0170.07317.92
5.5.320.0170.07017.95
5.5.310.0170.06718.13
5.5.300.0030.08317.94
5.5.290.0130.07318.11
5.5.280.0030.09017.96
5.5.270.0170.07017.93
5.5.260.0000.06018.25
5.5.250.0100.07317.91
5.5.240.0230.06017.62
5.5.230.0100.04717.32
5.5.220.0070.07017.21
5.5.210.0030.04717.29
5.5.200.0070.04317.29
5.5.190.0030.04717.28
5.5.180.0230.03017.45
5.5.160.0030.06717.28
5.5.150.0130.06317.45
5.5.140.0030.08317.18
5.5.130.0070.05317.27
5.5.120.0070.05317.31
5.5.110.0100.05017.47
5.5.100.0070.07717.10
5.5.90.0030.07017.35
5.5.80.0100.07317.09
5.5.70.0100.03717.31
5.5.60.0030.07017.21
5.5.50.0070.06017.16
5.5.40.0070.07017.29
5.5.30.0030.04017.34
5.5.20.0030.06717.47
5.5.10.0030.04717.16
5.5.00.0130.05717.33
5.4.450.0070.08319.51
5.4.440.0170.07019.27
5.4.430.0070.04719.35
5.4.420.0030.06019.29
5.4.410.0070.05319.42
5.4.400.0070.04319.02
5.4.390.0130.05719.01
5.4.380.0070.06718.95
5.4.370.0100.06719.01
5.4.360.0070.03719.18
5.4.350.0030.06719.14
5.4.340.0070.03719.31
5.4.320.0070.07019.14
5.4.310.0130.07719.14
5.4.300.0100.07319.02
5.4.290.0000.08318.98
5.4.280.0100.07019.08
5.4.270.0070.08319.31
5.4.260.0070.06019.31
5.4.250.0030.04719.15
5.4.240.0030.04718.98
5.4.230.0030.07319.15
5.4.220.0000.04718.98
5.4.210.0130.04319.00
5.4.200.0070.06018.96
5.4.190.0100.07319.17
5.4.180.0100.07319.25
5.4.170.0070.04319.23
5.4.160.0000.04319.16
5.4.150.0000.04019.00
5.4.140.0030.05016.64
5.4.130.0130.05716.62
5.4.120.0030.03316.54
5.4.110.0000.04716.33
5.4.100.0000.08016.52
5.4.90.0100.06716.63
5.4.80.0100.06716.60
5.4.70.0100.05716.58
5.4.60.0030.06716.48
5.4.50.0100.06716.35
5.4.40.0030.06016.52
5.4.30.0200.06316.50
5.4.20.0070.03016.50
5.4.10.0030.04316.53
5.4.00.0030.04315.94
5.3.290.0070.04314.75
5.3.280.0100.07014.75
5.3.270.0070.07014.64
5.3.260.0030.04014.66
5.3.250.0000.08014.66
5.3.240.0130.05014.77
5.3.230.0070.05714.71
5.3.220.0000.05714.72
5.3.210.0100.04014.82
5.3.200.0030.03314.63
5.3.190.0070.07314.70
5.3.180.0070.07014.71
5.3.170.0100.06314.67
5.3.160.0070.04014.55
5.3.150.0030.03714.45
5.3.140.0030.06314.61
5.3.130.0000.07314.59
5.3.120.0000.07014.57
5.3.110.0070.05714.57
5.3.100.0000.03714.08
5.3.90.0030.03714.06
5.3.80.0030.03314.04
5.3.70.0000.03714.05
5.3.60.0170.05714.16
5.3.50.0130.05714.00
5.3.40.0070.03714.11
5.3.30.0030.05013.95
5.3.20.0000.04013.85
5.3.10.0030.06013.69
5.3.00.0070.07013.77
5.2.170.0000.05712.30
5.2.160.0000.02712.30
5.2.150.0030.02312.30
5.2.140.0030.06712.30
5.2.130.0100.05712.30
5.2.120.0130.05712.30
5.2.110.0100.06012.30
5.2.100.0030.06312.30
5.2.90.0000.02712.30
5.2.80.0000.03712.30
5.2.70.0030.06012.30
5.2.60.0030.04312.30
5.2.50.0030.02712.30
5.2.40.0030.02712.30
5.2.30.0100.05712.30
5.2.20.0030.03712.30
5.2.10.0130.04712.30
5.2.00.0000.02712.30
5.1.60.0000.03712.30
5.1.50.0030.02312.30
5.1.40.0070.05012.30
5.1.30.0070.05712.30
5.1.20.0100.03012.30
5.1.10.0030.02312.30
5.1.00.0030.02712.30
5.0.50.0070.02312.30
5.0.40.0030.02012.30
5.0.30.0030.03012.30
5.0.20.0070.01312.30
5.0.10.0070.01312.30
5.0.00.0000.03312.30
4.4.90.0000.03312.30
4.4.80.0000.02012.30
4.4.70.0000.01712.30
4.4.60.0070.03012.30
4.4.50.0000.03012.30
4.4.40.0000.05312.30
4.4.30.0000.01712.30
4.4.20.0030.01012.30
4.4.10.0030.01312.30
4.4.00.0000.03012.30
4.3.110.0030.01312.30
4.3.100.0000.01712.30
4.3.90.0000.01712.30
4.3.80.0000.02312.30
4.3.70.0000.01312.30
4.3.60.0000.01312.30
4.3.50.0030.01312.30
4.3.40.0030.02012.30
4.3.30.0030.01012.30
4.3.20.0000.01312.30
4.3.10.0000.01312.30
4.3.00.0000.01312.30

preferences:
40.64 ms | 401 KiB | 5 Q