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(CSP::DEFAULT_SRC, CSP::SOURCE_SELF); 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.00018.43
8.3.50.0120.00321.21
8.3.40.0140.00318.98
8.3.30.0070.00720.17
8.3.20.0050.00320.29
8.3.10.0040.00421.92
8.3.00.0000.00822.46
8.2.180.0140.00716.88
8.2.170.0070.01422.96
8.2.160.0030.01022.26
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00420.75
8.2.110.0100.00020.57
8.2.100.0040.00817.72
8.2.90.0050.00517.88
8.2.80.0040.00418.04
8.2.70.0080.00017.91
8.2.60.0000.00818.05
8.2.50.0030.00518.10
8.2.40.0000.00719.32
8.2.30.0070.00019.20
8.2.20.0040.00417.60
8.2.10.0050.00317.64
8.2.00.0040.00417.69
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0060.00323.84
8.1.230.0080.00420.88
8.1.220.0060.00317.74
8.1.210.0030.00520.76
8.1.200.0060.00317.35
8.1.190.0060.00317.25
8.1.180.0050.00318.10
8.1.170.0000.00818.41
8.1.160.0040.00418.78
8.1.150.0000.00718.79
8.1.140.0000.00717.38
8.1.130.0030.00317.85
8.1.120.0040.00417.47
8.1.110.0040.00417.42
8.1.100.0000.00717.34
8.1.90.0030.00517.48
8.1.80.0070.00017.30
8.1.70.0000.00817.38
8.1.60.0030.00617.64
8.1.50.0000.00717.52
8.1.40.0040.00817.39
8.1.30.0000.00817.70
8.1.20.0060.00317.68
8.1.10.0040.00417.62
8.1.00.0040.00417.41
8.0.300.0050.00319.65
8.0.290.0060.00316.75
8.0.280.0030.00318.32
8.0.270.0000.00717.18
8.0.260.0070.00016.84
8.0.250.0030.00317.04
8.0.240.0000.00916.87
8.0.230.0070.00016.96
8.0.220.0000.00716.78
8.0.210.0070.00016.79
8.0.200.0060.00016.98
8.0.190.0000.00916.95
8.0.180.0070.00016.83
8.0.170.0090.00016.75
8.0.160.0000.00716.90
8.0.150.0000.00716.75
8.0.140.0060.00316.90
8.0.130.0000.00613.35
8.0.120.0040.00416.88
8.0.110.0020.00516.95
8.0.100.0040.00416.82
8.0.90.0030.00516.71
8.0.80.0120.00916.94
8.0.70.0050.00216.93
8.0.60.0070.00016.78
8.0.50.0070.00016.95
8.0.30.0130.01017.20
8.0.20.0050.01317.40
8.0.10.0070.00017.04
8.0.00.0050.01416.76
7.4.330.0050.00016.77
7.4.320.0000.00616.53
7.4.300.0040.00416.55
7.4.290.0030.00316.54
7.4.280.0030.00316.48
7.4.270.0000.00716.66
7.4.260.0030.00313.30
7.4.250.0040.00416.51
7.4.240.0020.00516.52
7.4.230.0000.00716.70
7.4.220.0090.00916.72
7.4.210.0140.00516.55
7.4.200.0070.00016.68
7.4.190.0070.00016.69
7.4.160.0130.00316.43
7.4.150.0000.02017.40
7.4.140.0110.00917.86
7.4.130.0080.00816.53
7.4.120.0080.00916.55
7.4.110.0100.01116.60
7.4.100.0140.00716.61
7.4.90.0110.00616.71
7.4.80.0120.00619.39
7.4.70.0100.00616.50
7.4.60.0070.01016.49
7.4.50.0030.00316.36
7.4.40.0130.00322.77
7.4.30.0110.00616.36
7.4.10.0030.01315.14
7.4.00.0050.01015.01
7.3.330.0030.00313.46
7.3.320.0030.00313.28
7.3.310.0000.00716.48
7.3.300.0000.00716.32
7.3.290.0040.01116.50
7.3.280.0110.00916.41
7.3.270.0100.01017.40
7.3.260.0060.01818.24
7.3.250.0090.00916.41
7.3.240.0040.01416.44
7.3.230.0070.01116.48
7.3.210.0080.00816.53
7.3.200.0090.01219.39
7.3.190.0110.00716.44
7.3.180.0130.00316.45
7.3.170.0130.00316.46
7.3.160.0100.00716.42
7.3.130.0150.00414.77
7.3.120.0070.00914.85
7.3.110.0110.00614.79
7.3.100.0030.00914.81
7.3.90.0090.00314.87
7.3.80.0050.00714.89
7.3.70.0050.00814.66
7.3.60.0070.00614.70
7.3.50.0020.00814.65
7.3.40.0080.00514.99
7.3.30.0060.00814.89
7.3.20.0060.00516.83
7.3.10.0060.00916.59
7.3.00.0070.00616.37
7.2.330.0090.00916.57
7.2.320.0100.00716.71
7.2.310.0000.02116.61
7.2.300.0090.00816.68
7.2.290.0090.00916.49
7.2.260.0030.01215.17
7.2.250.0020.01715.01
7.2.240.0030.01215.13
7.2.230.0120.00315.25
7.2.220.0020.00915.01
7.2.210.0030.01014.97
7.2.200.0110.00415.02
7.2.190.0030.01014.86
7.2.180.0080.00615.09
7.2.170.0070.00415.10
7.2.160.0000.01715.08
7.2.150.0080.00316.77
7.2.140.0110.00416.61
7.2.130.0090.00816.87
7.2.120.0110.00616.54
7.2.110.0110.01016.55
7.2.100.0100.00816.81
7.2.90.0080.00716.61
7.2.80.0100.01016.75
7.2.70.0040.01316.52
7.2.60.0080.00616.65
7.2.50.0100.00816.71
7.2.40.0110.00816.66
7.2.30.0100.00516.71
7.2.20.0100.00616.58
7.2.10.0100.00616.37
7.2.00.0060.00517.55
7.1.330.0000.01515.81
7.1.320.0040.00515.79
7.1.310.0100.00315.90
7.1.300.0050.01015.81
7.1.290.0070.00515.71
7.1.280.0060.00415.64
7.1.270.0100.00315.74
7.1.260.0070.00715.59
7.1.250.0080.01015.54
7.1.240.0060.01015.73
7.1.230.0060.00915.77
7.1.220.0000.01315.91
7.1.210.0080.00415.85
7.1.200.0060.00815.90
7.1.190.0040.00815.55
7.1.180.0100.00715.71
7.1.170.0030.00915.73
7.1.160.0030.00615.56
7.1.150.0060.00615.80
7.1.140.0090.00615.82
7.1.130.0000.01115.88
7.1.120.0070.00715.84
7.1.110.0030.00715.97
7.1.100.0080.00917.01
7.1.90.0040.00715.93
7.1.80.0000.01415.94
7.1.70.0030.00716.47
7.1.60.0090.01017.38
7.1.50.0070.00716.43
7.1.40.0030.01415.64
7.1.30.0000.01115.80
7.1.20.0040.01115.89
7.1.10.0060.00915.68
7.1.00.0080.02219.00
7.0.330.0100.00315.55
7.0.320.0040.00715.09
7.0.310.0060.00615.44
7.0.300.0040.01115.11
7.0.290.0000.01415.58
7.0.280.0140.00015.43
7.0.270.0060.00315.57
7.0.260.0070.00715.36
7.0.250.0060.01015.26
7.0.240.0030.00615.28
7.0.230.0070.00715.43
7.0.220.0000.01615.50
7.0.210.0000.01115.45
7.0.200.0020.00916.02
7.0.190.0070.00715.55
7.0.180.0080.00815.22
7.0.170.0030.01315.52
7.0.160.0030.00915.47
7.0.150.0050.00315.33
7.0.140.0010.04118.68
7.0.130.0090.00315.52
7.0.120.0000.01215.32
7.0.110.0060.00315.16
7.0.100.0030.04217.62
7.0.90.0140.04017.64
7.0.80.0130.04617.74
7.0.70.0120.04917.71
7.0.60.0150.03817.67
7.0.50.0170.04517.88
7.0.40.0080.04216.74
7.0.30.0020.04516.76
7.0.20.0100.04216.71
7.0.10.0070.04416.79
7.0.00.0080.02816.83
5.6.400.0030.01314.53
5.6.390.0070.00314.68
5.6.380.0030.00614.06
5.6.370.0000.01114.79
5.6.360.0120.00314.67
5.6.350.0070.01014.31
5.6.340.0040.01214.38
5.6.330.0000.01214.70
5.6.320.0100.00614.48
5.6.310.0000.01014.53
5.6.300.0130.00014.65
5.6.290.0130.00314.59
5.6.280.0050.04117.88
5.6.270.0130.00314.79
5.6.260.0100.00614.50
5.6.250.0020.04717.54
5.6.240.0080.04017.59
5.6.230.0110.03617.65
5.6.220.0100.04317.57
5.6.210.0080.04317.54
5.6.200.0120.03917.79
5.6.190.0030.04717.72
5.6.180.0080.04217.91
5.6.170.0080.04617.73
5.6.160.0080.03217.77
5.6.150.0080.04017.64
5.6.140.0080.02717.69
5.6.130.0110.04117.87
5.6.120.0070.03917.74
5.6.110.0050.04917.84
5.6.100.0100.03817.85
5.6.90.0050.04517.69
5.6.80.0050.04217.41
5.6.70.0050.04117.39
5.6.60.0090.03917.34
5.6.50.0050.04517.48
5.6.40.0080.03517.42
5.6.30.0120.03717.35
5.6.20.0020.04217.37
5.6.10.0100.03917.30
5.6.00.0110.02317.37
5.5.380.0080.04517.52
5.5.370.0030.04017.36
5.5.360.0030.03617.46
5.5.350.0050.04217.36
5.5.340.0120.03517.63
5.5.330.0060.04417.59
5.5.320.0060.04317.75
5.5.310.0030.04717.60
5.5.300.0050.04117.58
5.5.290.0090.03717.70
5.5.280.0100.04317.62
5.5.270.0140.03717.79
5.5.260.0090.03617.68
5.5.250.0120.02317.41
5.5.240.0090.03517.22
5.5.230.0050.02217.29
5.5.220.0080.04317.42
5.5.210.0120.01817.33
5.5.200.0070.04417.15
5.5.190.0040.04717.22
5.5.180.0100.03217.38
5.5.170.0040.01214.39
5.5.160.0080.04217.29
5.5.150.0030.04617.33
5.5.140.0080.03717.26
5.5.130.0030.04417.29
5.5.120.0070.04317.22
5.5.110.0060.04317.24
5.5.100.0070.04217.18
5.5.90.0100.03517.20
5.5.80.0050.04117.26
5.5.70.0070.04417.16
5.5.60.0080.04117.18
5.5.50.0140.02817.11
5.5.40.0110.03817.18
5.5.30.0090.03517.19
5.5.20.0100.04317.10
5.5.10.0050.04516.98
5.5.00.0070.04017.04
5.4.450.0030.04215.65
5.4.440.0090.04015.66
5.4.430.0050.04315.69
5.4.420.0050.02515.52
5.4.410.0040.04115.46
5.4.400.0050.02115.54
5.4.390.0040.04315.48
5.4.380.0080.03315.43
5.4.370.0070.04315.47
5.4.360.0030.04315.48
5.4.350.0100.04015.50
5.4.340.0100.04115.44
5.4.330.0030.00711.83
5.4.320.0080.02715.54
5.4.310.0030.04115.46
5.4.300.0080.02515.55
5.4.290.0050.04415.43
5.4.280.0050.04015.39
5.4.270.0060.03915.35
5.4.260.0030.03015.35
5.4.250.0050.04515.43
5.4.240.0070.04115.36
5.4.230.0030.03015.49
5.4.220.0120.03815.45
5.4.210.0030.04715.43
5.4.200.0030.04115.43
5.4.190.0030.04515.48
5.4.180.0060.04015.38
5.4.170.0050.03715.49
5.4.160.0080.02615.43
5.4.150.0050.04415.43
5.4.140.0110.03614.14
5.4.130.0050.03714.14
5.4.120.0080.02614.05
5.4.110.0110.03514.11
5.4.100.0030.03214.16
5.4.90.0090.03914.16
5.4.80.0080.03514.07
5.4.70.0060.04014.13
5.4.60.0070.02514.10
5.4.50.0070.03914.15
5.4.40.0080.03314.11
5.4.30.0060.03814.12
5.4.20.0050.03514.10
5.4.10.0080.02114.04
5.4.00.0020.02613.82
5.3.290.0060.04113.25
5.3.280.0050.04613.25
5.3.270.0030.04513.28
5.3.260.0150.03513.26
5.3.250.0080.03213.28
5.3.240.0070.04013.23
5.3.230.0100.04213.23
5.3.220.0070.04213.24
5.3.210.0090.03913.28
5.3.200.0080.04313.21
5.3.190.0090.04113.21
5.3.180.0090.04313.25
5.3.170.0130.03713.27
5.3.160.0060.02613.27
5.3.150.0140.03513.23
5.3.140.0120.02513.25
5.3.130.0120.03913.17
5.3.120.0100.03613.25
5.3.110.0080.04113.23
5.3.100.0060.03112.99
5.3.90.0030.02712.97
5.3.80.0080.02712.95
5.3.70.0080.02112.90
5.3.60.0060.04012.89
5.3.50.0050.03112.90
5.3.40.0070.03912.87
5.3.30.0090.02112.95
5.3.20.0070.02412.76
5.3.10.0040.04212.73
5.3.00.0080.02012.78
5.2.170.0130.05311.09
5.2.160.0170.04011.27
5.2.150.0030.06311.05
5.2.140.0030.05311.27
5.2.130.0030.06311.21
5.2.120.0100.02710.98
5.2.110.0000.04011.25
5.2.100.0070.05711.26
5.2.90.0030.03711.04
5.2.80.0100.05311.18
5.2.70.0000.03711.03
5.2.60.0030.05010.99
5.2.50.0100.03711.07
5.2.40.0030.06311.16
5.2.30.0000.05011.11
5.2.20.0030.05710.89
5.2.10.0170.05010.80
5.2.00.0070.05710.85
5.1.60.0000.03010.09
5.1.50.0070.05010.13
5.1.40.0000.05710.02
5.1.30.0100.04710.39
5.1.20.0100.05710.41
5.1.10.0100.05310.16
5.1.00.0070.05310.21
5.0.50.0070.0478.80
5.0.40.0030.0278.80
5.0.30.0000.0678.80
5.0.20.0070.0408.80
5.0.10.0100.0378.80
5.0.00.0070.0378.80
4.4.90.0000.0408.80
4.4.80.0000.0378.80
4.4.70.0030.0178.80
4.4.60.0030.0208.80
4.4.50.0000.0378.80
4.4.40.0070.0478.80
4.4.30.0100.0108.80
4.4.20.0030.0308.80
4.4.10.0030.0338.80
4.4.00.0070.0508.80
4.3.110.0030.0238.80
4.3.100.0000.0308.80
4.3.90.0000.0308.80
4.3.80.0000.0608.80
4.3.70.0000.0378.80
4.3.60.0100.0238.80
4.3.50.0000.0208.80
4.3.40.0000.0438.80
4.3.30.0030.0278.80
4.3.20.0000.0308.80
4.3.10.0030.0308.80
4.3.00.0000.0308.80

preferences:
73.7 ms | 400 KiB | 5 Q