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.70.0110.00716.75
8.3.60.0150.00618.68
8.3.50.0110.00521.21
8.3.40.0120.00619.18
8.3.30.0110.00420.09
8.3.20.0080.00020.13
8.3.10.0060.00322.14
8.3.00.0050.00322.44
8.2.180.0090.00616.75
8.2.170.0070.00722.96
8.2.160.0030.01022.33
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0080.00020.88
8.2.110.0100.00022.21
8.2.100.0090.00319.76
8.2.90.0030.00518.34
8.2.80.0030.00617.97
8.2.70.0120.00217.63
8.2.60.0000.00817.93
8.2.50.0090.00018.07
8.2.40.0050.00318.15
8.2.30.0040.00419.48
8.2.20.0030.00517.95
8.2.10.0060.00318.03
8.2.00.0040.00417.88
8.1.280.0150.00325.92
8.1.270.0000.01023.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00622.65
8.1.230.0080.00421.16
8.1.220.0050.00317.91
8.1.210.0030.00618.82
8.1.200.0060.00317.60
8.1.190.0000.00917.47
8.1.180.0000.00818.10
8.1.170.0040.00418.91
8.1.160.0030.00618.97
8.1.150.0000.00818.89
8.1.140.0080.00017.70
8.1.130.0030.00317.88
8.1.120.0040.00417.66
8.1.110.0070.00017.60
8.1.100.0030.00617.71
8.1.90.0050.00217.65
8.1.80.0000.00717.48
8.1.70.0030.00317.61
8.1.60.0000.00917.80
8.1.50.0040.00417.69
8.1.40.0090.00317.76
8.1.30.0060.00317.80
8.1.20.0000.00817.87
8.1.10.0000.00817.79
8.1.00.0030.00617.59
8.0.300.0050.00319.98
8.0.290.0040.00417.00
8.0.280.0000.00818.52
8.0.270.0000.00717.36
8.0.260.0070.00017.09
8.0.250.0030.00317.07
8.0.240.0030.00617.22
8.0.230.0000.00717.17
8.0.220.0030.00317.03
8.0.210.0040.00417.12
8.0.200.0060.00317.24
8.0.190.0090.00017.11
8.0.180.0040.00417.13
8.0.170.0040.00417.11
8.0.160.0040.00417.07
8.0.150.0030.00517.13
8.0.140.0030.00717.15
8.0.130.0060.00013.66
8.0.120.0040.00416.97
8.0.110.0050.00217.01
8.0.100.0000.00717.04
8.0.90.0040.00417.04
8.0.80.0000.02017.14
8.0.70.0030.00517.15
8.0.60.0000.00917.05
8.0.50.0040.00417.13
8.0.30.0090.01117.31
8.0.20.0110.00917.50
8.0.10.0070.00017.31
8.0.00.0130.00517.09
7.4.330.0030.00216.80
7.4.320.0030.00316.77
7.4.300.0000.00816.85
7.4.290.0030.00516.84
7.4.280.0070.00016.67
7.4.270.0070.00016.66
7.4.260.0000.00513.59
7.4.250.0000.00816.70
7.4.240.0070.00016.69
7.4.230.0070.00016.65
7.4.220.0150.00316.92
7.4.210.0100.00616.82
7.4.200.0050.00316.61
7.4.190.0000.00816.93
7.4.160.0060.00916.74
7.4.150.0060.01217.40
7.4.140.0080.00917.86
7.4.130.0070.01316.75
7.4.120.0100.00816.66
7.4.110.0030.01416.67
7.4.100.0190.00616.84
7.4.90.0070.01016.89
7.4.80.0170.00719.39
7.4.70.0120.00916.68
7.4.60.0110.00716.75
7.4.50.0050.00316.67
7.4.40.0090.00622.77
7.4.30.0100.00716.66
7.4.10.0100.00615.32
7.4.00.0070.01015.15
7.3.330.0050.00013.75
7.3.320.0000.00613.66
7.3.310.0040.00416.46
7.3.300.0070.00016.48
7.3.290.0030.01016.59
7.3.280.0090.00716.60
7.3.270.0170.00017.40
7.3.260.0200.00718.24
7.3.250.0180.00316.87
7.3.240.0090.00916.63
7.3.230.0100.00716.60
7.3.210.0090.00616.72
7.3.200.0070.01019.39
7.3.190.0120.01216.88
7.3.180.0070.01416.90
7.3.170.0130.00316.87
7.3.160.0130.00316.71
7.3.130.0110.00615.23
7.3.120.0080.00815.13
7.3.110.0090.00915.10
7.3.100.0020.01115.07
7.3.90.0030.01015.09
7.3.80.0070.00715.23
7.3.70.0050.00915.11
7.3.60.0100.00614.98
7.3.50.0050.00814.91
7.3.40.0060.00715.02
7.3.30.0050.00415.21
7.3.20.0100.00516.91
7.3.10.0040.00816.82
7.3.00.0060.00516.67
7.2.330.0070.01016.89
7.2.320.0070.01017.02
7.2.310.0180.00016.82
7.2.300.0040.01316.74
7.2.290.0150.00316.75
7.2.260.0030.01315.28
7.2.250.0090.00915.37
7.2.240.0030.01515.39
7.2.230.0050.01215.25
7.2.220.0050.01115.20
7.2.210.0020.01215.24
7.2.200.0050.00715.42
7.2.190.0040.01215.10
7.2.180.0020.01415.20
7.2.170.0070.00815.38
7.2.160.0030.01015.20
7.2.150.0000.01516.94
7.2.140.0060.00617.27
7.2.130.0030.01017.12
7.2.120.0120.00316.96
7.2.110.0100.00017.09
7.2.100.0030.01017.14
7.2.90.0030.01017.21
7.2.80.0070.00717.23
7.2.70.0000.00917.26
7.2.60.0070.00716.98
7.2.50.0070.00317.21
7.2.40.0060.00917.09
7.2.30.0000.01717.12
7.2.20.0060.00316.79
7.2.10.0030.00717.23
7.2.00.0060.00518.41
7.1.330.0030.01116.09
7.1.320.0070.00716.11
7.1.310.0050.00515.97
7.1.300.0050.00815.82
7.1.290.0010.01015.90
7.1.280.0100.00516.06
7.1.270.0100.00316.01
7.1.260.0060.00515.93
7.1.250.0030.01015.68
7.1.240.0070.01115.93
7.1.230.0110.00015.91
7.1.220.0040.01116.00
7.1.210.0060.00616.18
7.1.200.0030.00915.96
7.1.190.0000.01315.86
7.1.180.0040.00415.92
7.1.170.0060.00615.80
7.1.160.0060.00815.92
7.1.150.0040.00816.19
7.1.140.0030.00915.96
7.1.130.0030.00916.01
7.1.120.0050.00515.80
7.1.110.0000.01516.07
7.1.100.0030.00617.08
7.1.90.0000.00915.94
7.1.80.0000.01716.11
7.1.70.0090.00316.58
7.1.60.0030.01617.54
7.1.50.0060.01116.47
7.1.40.0040.00815.98
7.1.30.0000.01315.80
7.1.20.0060.00315.81
7.1.10.0070.00715.84
7.1.00.0040.01819.20
7.0.330.0100.00715.11
7.0.320.0070.00715.33
7.0.310.0060.00615.61
7.0.300.0080.00415.41
7.0.290.0040.00715.41
7.0.280.0100.00315.64
7.0.270.0060.00615.85
7.0.260.0090.00015.65
7.0.250.0030.00715.40
7.0.240.0120.00315.56
7.0.230.0040.00815.59
7.0.220.0070.00715.51
7.0.210.0040.00715.56
7.0.200.0070.00416.25
7.0.190.0040.00815.68
7.0.180.0100.00015.56
7.0.170.0000.00815.67
7.0.160.0000.00815.67
7.0.150.0000.01415.59
7.0.140.0030.04018.94
7.0.130.0130.00315.75
7.0.120.0070.01015.53
7.0.110.0080.00815.77
7.0.100.0080.02517.84
7.0.90.0080.03617.75
7.0.80.0110.02517.71
7.0.70.0240.04317.78
7.0.60.0250.03017.82
7.0.50.0200.03918.05
7.0.40.0070.02616.78
7.0.30.0100.02216.93
7.0.20.0080.04316.82
7.0.10.0110.04016.83
7.0.00.0070.02316.82
5.6.400.0000.01214.62
5.6.390.0030.01014.77
5.6.380.0030.01414.59
5.6.370.0070.00714.60
5.6.360.0030.01014.78
5.6.350.0040.00414.55
5.6.340.0090.00014.40
5.6.330.0000.01614.38
5.6.320.0040.01114.78
5.6.310.0030.00614.62
5.6.300.0030.01014.66
5.6.290.0040.00414.56
5.6.280.0060.04117.79
5.6.270.0000.01814.45
5.6.260.0030.01414.70
5.6.250.0050.03717.74
5.6.240.0130.03717.58
5.6.230.0070.04617.63
5.6.220.0070.04117.54
5.6.210.0050.03417.42
5.6.200.0120.04517.81
5.6.190.0080.04517.91
5.6.180.0070.03917.73
5.6.170.0120.04817.73
5.6.160.0100.04217.87
5.6.150.0120.03917.71
5.6.140.0050.02517.75
5.6.130.0070.02517.99
5.6.120.0050.03817.77
5.6.110.0150.03917.75
5.6.100.0030.03817.85
5.6.90.0090.04317.86
5.6.80.0110.02117.55
5.6.70.0090.04217.60
5.6.60.0100.03017.36
5.6.50.0130.03717.29
5.6.40.0120.03917.49
5.6.30.0050.04817.41
5.6.20.0020.04917.24
5.6.10.0060.04517.54
5.6.00.0080.03517.42
5.5.380.0070.03517.53
5.5.370.0050.02917.43
5.5.360.0070.03717.48
5.5.350.0100.04717.46
5.5.340.0100.03717.74
5.5.330.0060.04817.61
5.5.320.0070.04517.69
5.5.310.0050.03717.71
5.5.300.0150.03517.67
5.5.290.0030.04717.67
5.5.280.0050.04517.66
5.5.270.0080.03017.68
5.5.260.0140.04017.68
5.5.250.0140.02717.60
5.5.240.0110.02617.44
5.5.230.0080.03517.40
5.5.220.0120.03917.28
5.5.210.0110.03517.20
5.5.200.0090.03917.21
5.5.190.0110.03317.32
5.5.180.0070.04317.18
5.5.170.0040.00814.23
5.5.160.0050.03717.25
5.5.150.0080.04117.32
5.5.140.0160.03317.24
5.5.130.0080.03617.36
5.5.120.0030.02817.46
5.5.110.0080.03217.43
5.5.100.0030.03417.11
5.5.90.0060.03917.31
5.5.80.0030.04517.33
5.5.70.0090.04017.31
5.5.60.0080.03717.29
5.5.50.0080.04017.17
5.5.40.0050.03817.30
5.5.30.0060.02517.14
5.5.20.0080.02217.12
5.5.10.0050.04517.18
5.5.00.0080.03817.13
5.4.450.0050.04016.01
5.4.440.0140.03716.01
5.4.430.0000.02916.09
5.4.420.0080.03816.05
5.4.410.0040.02516.01
5.4.400.0070.03815.76
5.4.390.0060.03015.74
5.4.380.0080.03015.87
5.4.370.0070.02915.80
5.4.360.0030.04915.89
5.4.350.0050.04415.88
5.4.340.0050.04415.90
5.4.330.0060.00312.64
5.4.320.0050.02415.88
5.4.310.0030.04515.91
5.4.300.0070.04215.93
5.4.290.0050.02315.76
5.4.280.0020.03115.90
5.4.270.0060.04115.87
5.4.260.0060.03115.84
5.4.250.0080.02815.94
5.4.240.0050.02415.79
5.4.230.0050.04015.85
5.4.220.0090.03615.83
5.4.210.0050.03315.79
5.4.200.0080.03815.83
5.4.190.0030.03815.77
5.4.180.0080.03515.86
5.4.170.0020.04515.75
5.4.160.0020.04515.92
5.4.150.0070.04115.83
5.4.140.0090.02114.51
5.4.130.0080.02114.57
5.4.120.0080.03814.56
5.4.110.0120.03314.58
5.4.100.0090.03314.60
5.4.90.0070.02414.60
5.4.80.0020.04114.59
5.4.70.0080.03314.58
5.4.60.0100.03214.61
5.4.50.0040.02814.53
5.4.40.0040.03914.57
5.4.30.0040.04014.56
5.4.20.0050.03814.45
5.4.10.0070.03814.56
5.4.00.0020.03614.25
5.3.290.0070.04213.68
5.3.280.0050.03813.59
5.3.270.0050.03713.68
5.3.260.0070.04013.71
5.3.250.0020.04613.65
5.3.240.0030.04313.67
5.3.230.0070.03813.62
5.3.220.0020.03313.60
5.3.210.0050.04513.59
5.3.200.0080.04013.69
5.3.190.0020.04513.67
5.3.180.0080.03413.66
5.3.170.0050.03613.59
5.3.160.0070.03813.58
5.3.150.0070.02113.69
5.3.140.0020.03913.67
5.3.130.0070.04013.66
5.3.120.0020.02813.62
5.3.110.0080.03813.62
5.3.100.0080.03513.38
5.3.90.0070.04213.33
5.3.80.0050.04113.38
5.3.70.0000.04713.40
5.3.60.0050.03513.37
5.3.50.0050.04213.33
5.3.40.0030.02313.25
5.3.30.0120.03313.28
5.3.20.0060.03713.23
5.3.10.0030.03513.11
5.3.00.0080.03813.14
5.2.170.0070.02312.31
5.2.160.0000.06012.31
5.2.150.0070.06012.31
5.2.140.0030.06312.31
5.2.130.0030.05012.31
5.2.120.0100.05012.31
5.2.110.0030.03012.31
5.2.100.0030.04712.31
5.2.90.0100.05012.31
5.2.80.0030.03312.31
5.2.70.0070.06012.31
5.2.60.0030.03712.31
5.2.50.0000.06312.31
5.2.40.0070.03312.31
5.2.30.0000.03712.31
5.2.20.0030.04312.31
5.2.10.0030.06012.31
5.2.00.0170.04712.31
5.1.60.0030.04712.31
5.1.50.0030.05312.31
5.1.40.0030.03312.31
5.1.30.0070.05312.31
5.1.20.0100.05312.31
5.1.10.0000.05012.31
5.1.00.0000.04312.31
5.0.50.0030.05012.31
5.0.40.0070.05312.31
5.0.30.0000.07312.31
5.0.20.0070.04012.31
5.0.10.0000.02312.31
5.0.00.0030.05312.31
4.4.90.0030.03012.31
4.4.80.0070.03312.31
4.4.70.0030.01712.31
4.4.60.0030.01712.31
4.4.50.0070.03012.31
4.4.40.0030.06312.31
4.4.30.0100.01012.31
4.4.20.0030.03012.31
4.4.10.0070.03312.31
4.4.00.0030.03312.31
4.3.110.0000.03312.31
4.3.100.0000.03012.31
4.3.90.0030.01712.31
4.3.80.0000.05712.31
4.3.70.0030.03012.31
4.3.60.0000.03012.31
4.3.50.0100.02712.31
4.3.40.0030.04712.31
4.3.30.0000.03312.31
4.3.20.0000.02312.31
4.3.10.0030.03312.31
4.3.00.0000.03012.31

preferences:
60.2 ms | 401 KiB | 5 Q