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(); } 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(CSP::SCRIPT_SRC, CSP::SOURCE_SELF) ->addSource(CSP::SCRIPT_SRC, 'http://code.jquery.com') ->addSource(CSP::STYLE_SRC, 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.0140.00716.75
8.3.50.0130.00817.57
8.3.40.0110.01119.01
8.3.30.0040.01118.83
8.3.20.0000.00818.82
8.3.10.0040.00418.73
8.3.00.0080.00019.38
8.2.180.0200.00316.75
8.2.170.0070.00722.96
8.2.160.0090.00618.83
8.2.150.0040.00724.18
8.2.140.0000.00724.66
8.2.130.0040.00426.16
8.2.120.0050.00320.83
8.2.110.0070.00322.08
8.2.100.0090.00318.03
8.2.90.0030.00617.75
8.2.80.0040.00417.97
8.2.70.0030.00518.04
8.2.60.0000.00818.03
8.2.50.0060.00318.10
8.2.40.0100.00020.51
8.2.30.0060.00318.18
8.2.20.0030.00519.57
8.2.10.0000.00717.81
8.2.00.0030.00517.70
8.1.280.0100.00725.92
8.1.270.0060.00324.66
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0030.00720.44
8.1.230.0060.00619.16
8.1.220.0080.00017.74
8.1.210.0060.00318.77
8.1.200.0000.00917.23
8.1.190.0080.00017.35
8.1.180.0050.00318.10
8.1.170.0060.00318.59
8.1.160.0040.00418.98
8.1.150.0050.00218.65
8.1.140.0050.00317.42
8.1.130.0040.00417.75
8.1.120.0000.00817.51
8.1.110.0030.00517.42
8.1.100.0030.00517.36
8.1.90.0040.00417.54
8.1.80.0070.00017.40
8.1.70.0070.00017.33
8.1.60.0050.00317.61
8.1.50.0050.00317.48
8.1.40.0050.00217.48
8.1.30.0030.00517.68
8.1.20.0000.00817.57
8.1.10.0050.00217.64
8.1.00.0030.00517.52
8.0.300.0030.00619.69
8.0.290.0060.00316.75
8.0.280.0000.00718.46
8.0.270.0080.00017.25
8.0.260.0000.00716.95
8.0.250.0080.00017.05
8.0.240.0030.00317.10
8.0.230.0040.00316.94
8.0.220.0030.00316.85
8.0.210.0050.00317.00
8.0.200.0030.00316.94
8.0.190.0040.00417.03
8.0.180.0040.00417.04
8.0.170.0050.00316.88
8.0.160.0040.00416.82
8.0.150.0090.00016.81
8.0.140.0030.00716.93
8.0.130.0000.00513.32
8.0.120.0070.00016.91
8.0.110.0000.00716.98
8.0.100.0000.00716.99
8.0.90.0000.00716.95
8.0.80.0070.01016.94
8.0.70.0040.00416.86
8.0.60.0050.00316.80
8.0.50.0000.00817.04
8.0.30.0110.00716.79
8.0.20.0060.01316.91
8.0.10.0050.00217.08
8.0.00.0120.00616.81
7.4.330.0050.00013.02
7.4.320.0030.00316.58
7.4.300.0030.00316.51
7.4.290.0030.00716.41
7.4.280.0070.00016.52
7.4.270.0000.00716.46
7.4.260.0000.00513.24
7.4.250.0000.00916.59
7.4.240.0020.00516.55
7.4.230.0000.00716.27
7.4.220.0100.01116.46
7.4.210.0090.00716.55
7.4.200.0030.00316.70
7.4.190.0000.00716.53
7.4.160.0060.01016.61
7.4.150.0090.00916.55
7.4.140.0080.01016.47
7.4.130.0120.00616.57
7.4.120.0070.01116.59
7.4.110.0070.01416.66
7.4.100.0080.00816.65
7.4.90.0070.01116.60
7.4.80.0030.01419.39
7.4.70.0060.01016.59
7.4.60.0140.00316.59
7.4.50.0060.00616.66
7.4.40.0040.01116.16
7.4.30.0130.00316.71
7.4.00.0070.01014.77
7.3.330.0030.00313.24
7.3.320.0060.00013.41
7.3.310.0000.00716.47
7.3.300.0000.00716.42
7.3.290.0130.00716.46
7.3.280.0150.00516.42
7.3.270.0130.00716.46
7.3.260.0090.01516.58
7.3.250.0130.00816.47
7.3.240.0090.00916.38
7.3.230.0060.01216.53
7.3.210.0100.00716.65
7.3.200.0130.00916.37
7.3.190.0030.01416.54
7.3.180.0050.01116.52
7.3.170.0160.00016.66
7.3.160.0070.01016.49
7.3.120.0070.00915.00
7.2.330.0130.00716.38
7.2.320.0070.01016.49
7.2.310.0110.00716.55
7.2.300.0040.01216.77
7.2.290.0030.01316.71
7.2.60.0090.00616.85
7.2.00.0070.01119.36
7.1.200.0030.00615.78
7.1.100.0030.00618.15
7.1.70.0070.00717.26
7.1.60.0130.01319.40
7.1.50.0060.01617.11
7.1.00.0030.06722.36
7.0.200.0040.00416.71
7.0.140.0000.07322.00
7.0.120.0030.03022.09
7.0.60.0100.07319.93
7.0.50.0070.08317.91
7.0.40.0070.05020.40
7.0.30.0230.08720.28
7.0.20.0230.08720.19
7.0.10.0370.07020.15
7.0.00.0100.04320.09
5.6.280.0030.07321.14
5.6.210.0100.05720.59
5.6.200.0100.08318.22
5.6.190.0130.08020.64
5.6.180.0330.07720.75
5.6.170.0330.06720.44
5.6.160.0100.07320.50
5.6.150.0100.03318.19
5.6.140.0070.04018.15
5.6.130.0000.06018.29
5.6.120.0070.06721.00
5.6.110.0070.04321.16
5.6.100.0070.04321.00
5.6.90.0070.07721.05
5.6.80.0100.03720.40
5.6.70.0300.06320.42
5.5.350.0330.07020.43
5.5.340.0070.07317.99
5.5.330.0100.05320.27
5.5.320.0000.04320.19
5.5.310.0330.06320.23
5.5.300.0130.07017.98
5.5.290.0070.05318.07
5.5.280.0130.07320.71
5.5.270.0130.07720.91
5.5.260.0170.07720.86
5.5.250.0130.08320.73
5.5.240.0100.07720.29
5.4.450.0230.04319.38
5.4.440.0100.04719.48
5.4.430.0200.08019.53
5.4.420.0170.05019.19
5.4.410.0230.04319.19
5.4.400.0230.04019.20
5.4.390.0270.05019.24
5.4.380.0230.04018.95
5.4.370.0230.06719.08
5.4.360.0200.04019.09
5.4.350.0230.03719.17
5.4.340.0200.04019.16
5.4.320.0200.03319.06
5.4.310.0170.03718.86
5.4.300.0230.03719.08
5.4.290.0170.03718.95
5.4.280.0130.04019.20
5.4.270.0170.04719.19
5.4.260.0270.06719.30
5.4.250.0170.04719.30
5.4.240.0170.03719.22
5.4.230.0230.08018.94
5.4.220.0170.04719.16
5.4.210.0130.06319.07
5.4.200.0130.04019.14
5.4.190.0130.05719.12
5.4.180.0030.03719.29
5.4.170.0170.04718.94
5.4.160.0200.04319.21
5.4.150.0330.06719.00
5.4.140.0270.03716.56
5.4.130.0230.03016.44
5.4.120.0100.04316.54
5.4.110.0070.03316.57
5.4.100.0030.03716.60
5.4.90.0200.03316.58
5.4.80.1970.03716.28
5.4.70.2170.04016.41
5.4.60.1970.03716.35
5.4.50.2000.04316.48
5.4.40.1900.03716.34
5.4.30.2070.03316.35
5.4.20.1970.03716.42
5.4.10.2030.04016.53
5.4.00.1770.03316.13
5.3.290.1700.03714.80
5.3.280.0730.05314.64
5.3.270.0100.03314.71
5.3.260.0000.07714.53
5.3.250.1430.04314.64
5.3.240.2070.04714.60
5.3.230.2000.04714.61
5.3.220.1930.04314.82
5.3.210.2000.05014.82
5.3.200.1770.03714.74
5.3.190.1800.03714.56
5.3.180.2070.03714.50
5.3.170.2030.04314.49
5.3.160.2000.04314.59
5.3.150.2070.04014.61
5.3.140.2000.04714.80
5.3.130.2070.04314.58
5.3.120.1930.03014.47
5.3.110.2100.04014.49
5.3.100.1930.04713.97
5.3.90.2130.04014.05
5.3.80.1870.03313.95
5.3.70.1800.03313.95
5.3.60.2100.03313.93
5.3.50.2030.03714.08
5.3.40.0630.05313.88
5.3.30.0070.03714.16
5.3.20.0130.04013.73
5.3.10.1930.04313.62
5.3.00.2070.04313.78
5.2.170.1530.03311.39
5.2.160.1700.03011.12
5.2.150.1770.03711.08
5.2.140.1630.03311.14
5.2.130.1600.02311.04
5.2.120.1630.02711.21
5.2.110.1570.03011.02
5.2.100.1530.03011.13
5.2.90.1800.02311.13
5.2.80.1570.02711.02
5.2.70.0070.03010.98
5.2.60.0100.02011.00
5.2.50.0000.03011.27
5.2.40.0770.03011.02
5.2.30.1530.03010.91
5.2.20.1270.02711.10
5.2.10.1370.03310.84
5.2.00.1400.03010.82
5.1.60.1230.02310.07
5.1.50.1500.0239.92
5.1.40.1230.02010.08
5.1.30.1200.02710.50
5.1.20.1400.03010.45
5.1.10.1370.03010.03
5.1.00.1430.02710.17
5.0.50.0800.0208.46
5.0.40.0730.0138.32
5.0.30.0600.0308.18
5.0.20.0600.0208.23
5.0.10.0700.0238.33
5.0.00.0000.0308.24
4.4.90.0030.0238.18
4.4.80.0030.0178.18
4.4.70.0000.0178.18
4.4.60.0030.0138.18
4.4.50.0000.0178.18
4.4.40.0000.0308.18
4.4.30.0200.0138.18
4.4.20.0600.0178.18
4.4.10.0600.0178.18
4.4.00.0600.0278.18
4.3.110.0670.0178.18
4.3.100.0730.0178.18
4.3.90.0770.0278.19
4.3.80.0770.0308.19
4.3.70.0770.0208.19
4.3.60.0600.0138.19
4.3.50.0670.0208.19
4.3.40.0700.0238.19
4.3.30.0400.0178.19
4.3.20.0370.0178.19
4.3.10.0370.0108.19
4.3.00.0300.0138.19

preferences:
49.24 ms | 401 KiB | 5 Q