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.0110.00718.55
8.3.50.0160.00721.20
8.3.40.0070.01019.27
8.3.30.0060.00920.20
8.3.20.0040.00420.33
8.3.10.0080.00022.00
8.3.00.0040.00722.34
8.2.180.0080.01116.88
8.2.170.0150.00022.96
8.2.160.0090.00622.25
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0050.00326.16
8.2.120.0080.00020.97
8.2.110.0080.00322.14
8.2.100.0080.00417.96
8.2.90.0040.00419.20
8.2.80.0030.00619.21
8.2.70.0050.00317.88
8.2.60.0030.00717.93
8.2.50.0040.00418.07
8.2.40.0080.00018.21
8.2.30.0040.00419.57
8.2.20.0040.00417.98
8.2.10.0000.00817.98
8.2.00.0040.00418.11
8.1.280.0040.01425.92
8.1.270.0060.00323.99
8.1.260.0040.00426.35
8.1.250.0030.00628.09
8.1.240.0030.00623.97
8.1.230.0060.00619.34
8.1.220.0030.00517.88
8.1.210.0080.00018.77
8.1.200.0100.00017.73
8.1.190.0080.00017.55
8.1.180.0040.00418.10
8.1.170.0030.00518.84
8.1.160.0060.00318.92
8.1.150.0040.00418.71
8.1.140.0000.00717.60
8.1.130.0070.00017.92
8.1.120.0060.00317.70
8.1.110.0000.00817.52
8.1.100.0040.00417.67
8.1.90.0050.00317.57
8.1.80.0030.00517.64
8.1.70.0030.00317.65
8.1.60.0040.00417.84
8.1.50.0030.00617.70
8.1.40.0040.00717.63
8.1.30.0030.00617.82
8.1.20.0050.00317.82
8.1.10.0040.00417.78
8.1.00.0050.00317.67
8.0.300.0040.00418.77
8.0.290.0000.00817.30
8.0.280.0040.00318.40
8.0.270.0030.00317.25
8.0.260.0030.00317.03
8.0.250.0040.00417.25
8.0.240.0110.00017.21
8.0.230.0000.00717.27
8.0.220.0030.00317.19
8.0.210.0070.00017.16
8.0.200.0030.00317.11
8.0.190.0030.00617.14
8.0.180.0000.00717.19
8.0.170.0000.00817.10
8.0.160.0000.00717.07
8.0.150.0040.00317.07
8.0.140.0100.00017.00
8.0.130.0030.00313.61
8.0.120.0060.00317.00
8.0.110.0070.00017.02
8.0.100.0000.00817.13
8.0.90.0050.00317.10
8.0.80.0100.00717.15
8.0.70.0050.00217.23
8.0.60.0040.00417.12
8.0.50.0050.00217.10
8.0.30.0110.00717.50
8.0.20.0090.01417.40
8.0.10.0040.00417.13
8.0.00.0050.01316.96
7.4.330.0050.00016.78
7.4.320.0030.00316.91
7.4.300.0030.00316.74
7.4.290.0040.00416.87
7.4.280.0030.00316.80
7.4.270.0030.00316.77
7.4.260.0000.00513.50
7.4.250.0030.00516.87
7.4.240.0050.00316.82
7.4.230.0030.00316.77
7.4.220.0040.01416.74
7.4.210.0080.00816.79
7.4.200.0030.00316.97
7.4.190.0000.00816.67
7.4.160.0130.00316.73
7.4.150.0190.00617.40
7.4.140.0110.00717.86
7.4.130.0130.00716.75
7.4.120.0110.00616.86
7.4.110.0100.00716.88
7.4.100.0070.01016.73
7.4.90.0070.01016.87
7.4.80.0090.01819.39
7.4.70.0060.01016.68
7.4.60.0130.00316.70
7.4.50.0030.00316.73
7.4.40.0090.00922.77
7.4.30.0140.00316.73
7.4.00.0030.01015.33
7.3.330.0060.00013.59
7.3.320.0030.00313.48
7.3.310.0040.00416.45
7.3.300.0070.00016.69
7.3.290.0110.00416.65
7.3.280.0100.00516.66
7.3.270.0060.01817.40
7.3.260.0120.00818.24
7.3.250.0110.01116.76
7.3.240.0040.01316.84
7.3.230.0080.00816.64
7.3.210.0100.01016.79
7.3.200.0090.01219.39
7.3.190.0160.00316.49
7.3.180.0060.01016.78
7.3.170.0060.00916.93
7.3.160.0110.00616.88
7.3.120.0100.00715.24
7.2.330.0160.00316.68
7.2.320.0060.01216.96
7.2.310.0070.01117.01
7.2.300.0040.01316.93
7.2.290.0090.00916.91
7.2.60.0030.01017.12
7.2.00.0060.01019.39
7.1.200.0110.00015.91
7.1.100.0030.00618.41
7.1.70.0030.01017.29
7.1.60.0100.01319.17
7.1.50.0080.00416.71
7.1.00.0030.03322.46
7.0.200.0030.00316.96
7.0.140.0100.06321.95
7.0.80.0030.05719.98
7.0.70.0000.08721.74
7.0.60.0330.04319.91
7.0.50.0170.07720.33
7.0.40.0170.07320.05
7.0.30.0100.05720.04
7.0.20.0170.06020.19
7.0.10.0070.06320.14
7.0.00.0070.05320.07
5.6.280.0030.07320.91
5.6.230.0100.08020.57
5.6.220.0070.06720.52
5.6.210.0030.08320.52
5.6.200.0030.09021.13
5.6.190.0170.07320.96
5.6.180.0100.07321.04
5.6.170.0070.04320.96
5.6.160.0100.06320.98
5.6.150.0070.06021.08
5.6.140.0100.08021.06
5.6.130.0170.09021.10
5.6.120.0070.08021.12
5.6.110.0100.08721.02
5.6.100.0100.04721.10
5.6.90.0030.07721.07
5.6.80.0100.07320.36
5.6.70.0070.04320.45
5.6.60.0100.07720.44
5.6.50.0100.07720.52
5.6.40.0030.08320.45
5.6.30.0130.06720.50
5.6.20.0030.08020.42
5.6.10.0070.08020.48
5.6.00.0100.07020.39
5.5.370.0070.07020.52
5.5.360.0100.05720.46
5.5.350.0100.05720.43
5.5.340.0070.08320.90
5.5.330.0100.08320.88
5.5.320.0100.06320.79
5.5.310.0070.06320.86
5.5.300.0100.04320.90
5.5.290.0030.09020.78
5.5.280.0070.09020.89
5.5.270.0130.08320.77
5.5.260.0030.08320.85
5.5.250.0170.08020.63
5.5.240.0100.05020.27
5.5.230.0070.08020.23
5.5.220.0100.04720.28
5.5.210.0070.04320.30
5.5.200.0030.08320.21
5.5.190.0000.08720.15
5.5.180.0100.07720.13
5.5.160.0130.08020.24
5.5.150.0170.06720.23
5.5.140.0130.07320.29
5.5.130.0000.08720.13
5.5.120.0100.07320.25
5.5.110.0070.05320.25
5.5.100.0170.07320.07
5.5.90.0070.07320.00
5.5.80.0070.04720.00
5.5.70.0030.04020.06
5.5.60.0130.04020.02
5.5.50.0070.08020.11
5.5.40.0130.06320.08
5.5.30.0070.04320.11
5.5.20.0100.03320.10
5.5.10.0000.05020.13
5.5.00.0000.05020.12
5.4.450.0070.07319.38
5.4.440.0100.04019.48
5.4.430.0100.06019.35
5.4.420.0070.08319.57
5.4.410.0070.07019.32
5.4.400.0100.07319.13
5.4.390.0000.07719.05
5.4.380.0070.06718.88
5.4.370.0000.08019.16
5.4.360.0130.07319.04
5.4.350.0100.07719.23
5.4.340.0070.08019.18
5.4.320.0130.07019.14
5.4.310.0100.07719.13
5.4.300.0130.07019.23
5.4.290.0070.06018.87
5.4.280.0000.06019.13
5.4.270.0100.07019.13
5.4.260.0030.06319.12
5.4.250.0100.05019.17
5.4.240.0070.04318.89
5.4.230.0000.04319.11
5.4.220.0070.03719.05
5.4.210.0000.04019.15
5.4.200.0070.03719.22
5.4.190.0070.04019.11
5.4.180.0130.03018.86
5.4.170.0070.03319.20
5.4.160.0030.03319.20
5.4.150.0100.03019.21
5.4.140.0030.05716.46
5.4.130.0070.02716.51
5.4.120.0070.03016.32
5.4.110.0030.03016.54
5.4.100.0070.05016.40
5.4.90.0070.06016.52
5.4.80.0000.03716.43
5.4.70.0000.03716.37
5.4.60.0100.03016.48
5.4.50.0070.02716.38
5.4.40.0030.03316.35
5.4.30.0030.03716.26
5.4.20.0030.03316.45
5.4.10.0030.03716.34
5.4.00.0030.03315.91
5.3.290.0100.07714.81
5.3.280.0000.04014.61
5.3.270.0000.04314.77
5.3.260.0070.06714.65
5.3.250.0030.06014.74
5.3.240.0000.03714.60
5.3.230.0000.05714.58
5.3.220.0070.03714.68
5.3.210.0000.04014.71
5.3.200.0100.03014.66
5.3.190.0030.07314.55
5.3.180.0030.05314.57
5.3.170.0000.04014.65
5.3.160.0100.05714.65
5.3.150.0030.04014.66
5.3.140.0000.03314.60
5.3.130.0130.06314.64
5.3.120.0030.04714.50
5.3.110.0030.03314.50
5.3.100.0030.04714.10
5.3.90.0030.03713.98
5.3.80.0130.06714.06
5.3.70.0100.06714.15
5.3.60.0100.03714.12
5.3.50.0070.03714.11
5.3.40.0070.03314.11
5.3.30.0000.04714.00
5.3.20.0000.03713.67
5.3.10.0000.03713.77
5.3.00.0000.04013.73
5.2.170.0000.02711.73
5.2.160.0030.03311.73
5.2.150.0070.02711.73
5.2.140.0030.03311.73
5.2.130.0000.03011.73
5.2.120.0030.02711.73
5.2.110.0030.03011.73
5.2.100.0000.03011.73
5.2.90.0030.02711.73
5.2.80.0030.02711.73
5.2.70.0000.03011.73
5.2.60.0030.02711.73
5.2.50.0000.02711.73
5.2.40.0070.02711.73
5.2.30.0070.04011.73
5.2.20.0000.02711.73
5.2.10.0000.03311.73
5.2.00.0070.02311.73
5.1.60.0000.02311.73
5.1.50.0030.02311.73
5.1.40.0000.02311.73
5.1.30.0030.05711.73
5.1.20.0030.02011.73
5.1.10.0030.05711.73
5.1.00.0030.02011.73
5.0.50.0030.02011.73
5.0.40.0000.02011.73
5.0.30.0000.03011.73
5.0.20.0030.03311.73
5.0.10.0000.03311.73
5.0.00.0030.03011.73
4.4.90.0000.01311.73
4.4.80.0030.01311.73
4.4.70.0000.01711.73
4.4.60.0000.01711.73
4.4.50.0000.03311.73
4.4.40.0000.02311.73
4.4.30.0000.01711.73
4.4.20.0030.03711.73
4.4.10.0000.02711.73
4.4.00.0000.02311.73
4.3.110.0070.01011.73
4.3.100.0030.02711.73
4.3.90.0030.02011.73
4.3.80.0000.05011.73
4.3.70.0000.02011.73
4.3.60.0000.01711.73
4.3.50.0000.01311.73
4.3.40.0000.02711.73
4.3.30.0100.02711.73
4.3.20.0000.03711.73
4.3.10.0000.02711.73
4.3.00.0000.03011.73

preferences:
42.62 ms | 401 KiB | 5 Q