3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace owasp\csp; 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 'Content-Security-Policy: ' . join('; ', $retval); } } class CSPException extends \Exception {} use owasp\csp\ContentSecurityPolicy as CSP; $csp = (new CSP())->addSource(CSP::DEFAULT_SRC, CSP::SOURCE_SELF) ->addSource(CSP::SCRIPT_SRC, CSP::SOURCE_SELF) ->addSource(CSP::SCRIPT_SRC, 'http://code.jquery.com') ->addSource(CSP::STYLE_SRC, ContentSecurityPolicy::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.0160.00618.55
8.3.50.0070.01018.51
8.3.40.0100.01019.17
8.3.30.0150.00018.95
8.3.20.0060.00319.15
8.3.10.0000.00819.06
8.3.00.0060.00319.51
8.2.180.0110.00417.13
8.2.170.0120.00322.96
8.2.160.0100.00719.11
8.2.150.0030.00624.18
8.2.140.0090.00624.66
8.2.130.0000.00726.16
8.2.120.0090.00019.90
8.2.110.0100.00020.55
8.2.100.0080.00318.03
8.2.90.0000.00917.97
8.2.80.0050.00319.02
8.2.70.0040.00417.75
8.2.60.0040.00418.04
8.2.50.0080.00318.07
8.2.40.0080.00018.34
8.2.30.0060.00318.00
8.2.20.0060.00317.80
8.2.10.0080.00017.94
8.2.00.0040.00717.94
8.1.270.0050.00323.99
8.1.260.0030.00626.35
8.1.250.0000.00828.09
8.1.240.0060.00321.15
8.1.230.0080.00418.02
8.1.220.0030.00517.91
8.1.210.0030.00918.77
8.1.200.0060.00617.73
8.1.190.0000.00817.60
8.1.180.0080.00019.19
8.1.170.0000.00818.59
8.1.160.0040.00419.01
8.1.150.0050.00318.70
8.1.140.0080.00017.55
8.1.130.0000.00919.29
8.1.120.0040.00417.67
8.1.110.0040.00417.58
8.1.100.0000.00717.63
8.1.90.0050.00317.64
8.1.80.0000.00717.57
8.1.70.0030.00317.60
8.1.60.0040.00417.65
8.1.50.0040.00417.57
8.1.40.0030.00617.72
8.1.30.0060.00317.73
8.1.20.0030.00717.79
8.1.10.0000.00717.71
8.1.00.0000.00817.67
8.0.300.0020.00518.84
8.0.290.0040.00417.00
8.0.280.0030.00318.50
8.0.270.0000.00817.23
8.0.260.0000.00717.07
8.0.250.0030.00617.22
8.0.240.0040.00417.05
8.0.230.0000.00817.15
8.0.220.0000.00717.13
8.0.210.0040.00417.13
8.0.200.0030.00317.14
8.0.190.0000.00817.18
8.0.180.0000.00917.04
8.0.170.0040.00417.07
8.0.160.0040.00417.04
8.0.150.0000.00917.04
8.0.140.0000.00817.11
8.0.130.0030.00313.52
8.0.120.0030.00717.04
8.0.110.0000.00817.03
8.0.100.0000.00817.25
8.0.90.0070.00017.03
8.0.80.0090.01217.09
8.0.70.0000.00717.07
8.0.60.0040.00417.17
8.0.50.0000.00817.18
8.0.30.0070.00717.25
8.0.20.0200.00417.45
8.0.10.0060.00317.25
8.0.00.0100.01016.99
7.4.330.0050.00013.14
7.4.320.0030.00316.89
7.4.300.0030.00316.85
7.4.290.0060.00316.78
7.4.280.0060.00616.70
7.4.270.0030.00316.84
7.4.260.0000.00613.49
7.4.250.0030.00616.62
7.4.240.0040.00416.69
7.4.230.0000.00716.62
7.4.220.0090.00916.80
7.4.210.0060.01516.84
7.4.200.0000.00716.72
7.4.190.0040.00416.78
7.4.160.0030.01316.87
7.4.150.0090.00916.93
7.4.140.0110.01117.86
7.4.130.0120.01616.92
7.4.120.0090.01616.77
7.4.110.0070.01316.82
7.4.100.0080.00816.72
7.4.90.0100.01016.69
7.4.80.0120.00619.39
7.4.70.0080.00816.71
7.4.60.0130.00316.66
7.4.50.0030.00316.82
7.4.40.0060.01216.61
7.4.30.0090.00916.65
7.4.10.0070.01416.64
7.4.00.0090.00715.71
7.3.330.0040.00413.58
7.3.320.0070.00013.41
7.3.310.0060.00316.65
7.3.300.0030.00316.55
7.3.290.0050.00916.63
7.3.280.0100.01016.59
7.3.270.0130.00316.60
7.3.260.0170.00016.93
7.3.240.0060.01216.68
7.3.230.0080.01516.68
7.3.210.0110.00616.79
7.3.200.0090.00916.57
7.3.190.0030.01316.84
7.3.180.0080.01116.87
7.3.170.0090.01416.64
7.3.160.0130.00316.80
7.3.130.0090.00916.69
7.3.120.0080.00715.49
7.3.110.0050.01115.71
7.3.100.0050.01315.73
7.3.90.0060.00815.91
7.3.80.0090.00915.88
7.3.70.0040.01115.82
7.3.60.0090.00715.90
7.3.50.0060.01115.92
7.3.40.0050.00815.85
7.3.30.0030.00615.90
7.3.20.0090.00917.59
7.3.10.0060.00917.18
7.3.00.0060.00617.28
7.2.330.0080.01116.85
7.2.320.0140.00316.98
7.2.310.0150.00817.01
7.2.300.0080.00816.66
7.2.290.0030.01416.86
7.2.260.0030.01516.89
7.2.250.0100.00916.15
7.2.240.0080.00815.95
7.2.230.0070.00715.92
7.2.220.0060.00916.15
7.2.210.0060.00816.08
7.2.200.0070.00915.98
7.2.190.0000.01315.82
7.2.180.0050.01016.00
7.2.170.0050.00616.11
7.2.160.0040.00816.71
7.2.150.0070.01018.63
7.2.140.0050.00518.82
7.2.130.0030.01017.46
7.2.120.0100.00517.57
7.2.110.0110.00717.69
7.2.100.0060.00817.56
7.2.90.0060.00917.67
7.2.80.0090.00617.60
7.2.70.0100.00717.42
7.2.60.0070.00917.68
7.2.50.0090.00817.62
7.2.40.0080.00717.59
7.2.30.0090.00817.66
7.2.20.0020.01417.55
7.2.10.0110.00917.45
7.2.00.0080.00718.07
7.1.330.0050.00816.81
7.1.320.0050.00716.79
7.1.310.0040.01216.53
7.1.300.0060.00816.71
7.1.290.0070.00916.85
7.1.280.0020.01116.62
7.1.270.0000.01316.65
7.1.260.0030.01116.84
7.1.250.0120.00516.62
7.1.240.0080.00417.36
7.1.230.0030.00717.59
7.1.220.0070.00317.43
7.1.210.0060.00317.46
7.1.200.0070.00617.45
7.1.190.0080.00817.54
7.1.180.0100.00917.60
7.1.170.0070.00317.71
7.1.160.0040.01217.27
7.1.150.0030.01217.48
7.1.140.0000.01217.61
7.1.130.0080.00817.63
7.1.120.0080.00817.63
7.1.110.0090.00317.67
7.1.100.0010.00918.10
7.1.90.0040.01217.68
7.1.80.0000.01617.66
7.1.70.0070.00717.50
7.1.60.0100.00918.38
7.1.50.0090.00817.19
7.1.40.0030.00917.60
7.1.30.0060.00617.66
7.1.20.0070.00317.52
7.1.10.0100.00017.53
7.1.00.0050.02119.96
7.0.330.0090.00017.11
7.0.320.0030.00917.22
7.0.310.0100.00017.14
7.0.300.0060.00617.18
7.0.290.0000.01517.38
7.0.280.0030.01217.27
7.0.270.0070.01017.43
7.0.260.0050.00517.12
7.0.250.0120.00417.29
7.0.240.0040.01117.14
7.0.230.0000.01117.27
7.0.220.0100.00317.08
7.0.210.0060.00917.36
7.0.200.0090.01116.91
7.0.190.0030.01017.38
7.0.180.0000.01417.03
7.0.170.0050.00517.34
7.0.160.0040.00817.31
7.0.150.0030.00917.18
7.0.140.0020.04319.51
7.0.130.0000.01117.24
7.0.120.0030.04019.78
7.0.110.0030.01217.11
7.0.100.0090.00317.15
7.0.90.0030.00917.00
7.0.80.0080.00417.09
7.0.70.0000.01417.02
7.0.60.0100.04218.64
7.0.50.0040.03217.55
7.0.40.2180.02617.64
7.0.30.2050.02917.73
7.0.20.1880.02517.61
7.0.10.2020.02317.80
7.0.00.1960.01817.71
5.6.400.0030.01215.93
5.6.390.0060.00916.16
5.6.380.0070.00716.27
5.6.370.0040.00716.03
5.6.360.0110.00416.10
5.6.350.0070.00716.26
5.6.340.0030.01316.20
5.6.330.0060.00916.38
5.6.320.0130.00316.29
5.6.310.0050.00516.23
5.6.300.0030.01016.07
5.6.290.0150.00016.25
5.6.280.0030.04018.71
5.6.270.0100.00316.46
5.6.260.0000.00916.15
5.6.250.0000.01116.14
5.6.240.0030.01016.00
5.6.230.0040.01116.15
5.6.220.0080.00816.29
5.6.210.0040.02918.40
5.6.200.0070.03317.11
5.6.190.2240.03418.33
5.6.180.1650.02318.26
5.6.170.2150.02618.31
5.6.160.0280.03418.17
5.6.150.0070.04518.31
5.6.140.1730.02118.28
5.6.130.1950.03018.40
5.6.120.1180.03518.29
5.6.110.0050.04518.28
5.6.100.2100.02818.19
5.6.90.0040.02718.27
5.6.80.1310.02817.84
5.6.70.1730.02417.90
5.6.60.1750.02317.88
5.6.50.1690.02217.87
5.6.40.2130.02318.09
5.6.30.1950.02017.85
5.6.20.2150.02517.88
5.6.10.2130.02517.84
5.6.00.2210.01817.79
5.5.380.0030.00715.98
5.5.370.0040.00716.14
5.5.360.0100.00716.16
5.5.350.0180.02218.30
5.5.340.0060.04517.12
5.5.330.1000.03318.20
5.5.320.2030.02818.21
5.5.310.2160.02518.21
5.5.300.1560.02118.11
5.5.290.1760.02018.13
5.5.280.0050.04718.16
5.5.270.0020.03518.09
5.5.260.2050.02718.09
5.5.250.0070.02818.00
5.5.240.1700.02817.79
5.5.230.1900.02517.77
5.5.220.1690.02617.78
5.5.210.1870.02217.79
5.5.200.1670.02617.65
5.5.190.1970.02017.84
5.5.180.2050.02617.76
5.5.170.0100.00316.00
5.5.160.2730.01517.75
5.5.150.2190.02417.68
5.5.140.1980.02517.76
5.5.130.1790.02317.71
5.5.120.1920.02417.69
5.5.110.1600.02417.74
5.5.100.1870.02017.80
5.5.90.1830.02917.68
5.5.80.2080.02717.69
5.5.70.1670.02417.62
5.5.60.1670.02417.65
5.5.50.1700.02317.67
5.5.40.1600.02417.83
5.5.30.1380.02617.74
5.5.20.1360.02617.63
5.5.10.1650.01917.59
5.5.00.1880.02317.80
5.4.450.1880.02616.33
5.4.440.0020.03416.18
5.4.430.1320.02416.17
5.4.420.1980.02216.04
5.4.410.1870.02016.08
5.4.400.1860.01715.87
5.4.390.1750.02715.93
5.4.380.1830.02116.03
5.4.370.1820.02215.84
5.4.360.1880.02015.91
5.4.350.2170.01915.84
5.4.340.2130.02315.98
5.4.330.0030.00613.05
5.4.320.2000.02016.00
5.4.310.2170.01915.96
5.4.300.1730.02215.98
5.4.290.2070.02715.97
5.4.280.1750.02516.12
5.4.270.1920.02015.88
5.4.260.1780.02015.97
5.4.250.1750.02515.99
5.4.240.1630.02415.89
5.4.230.1550.02315.85
5.4.220.1530.01915.89
5.4.210.1730.01716.08
5.4.200.2220.01715.94
5.4.190.1400.02416.02
5.4.180.1700.02015.86
5.4.170.1700.01816.10
5.4.160.1680.02215.82
5.4.150.1920.02415.96
5.4.140.2220.01714.80
5.4.130.2030.02214.71
5.4.120.1880.02014.62
5.4.110.1630.02314.63
5.4.100.1930.02214.69
5.4.90.1980.02114.71
5.4.80.1600.02114.63
5.4.70.1750.02014.76
5.4.60.1770.02214.61
5.4.50.1840.01414.63
5.4.40.1780.02114.71
5.4.30.1900.02014.67
5.4.20.1820.02514.67
5.4.10.1680.02014.65
5.4.00.1880.02114.40
5.3.290.2190.02013.82
5.3.280.1920.02513.65
5.3.270.1800.02113.67
5.3.260.1780.02113.74
5.3.250.1920.02013.69
5.3.240.2120.01913.70
5.3.230.1850.02213.75
5.3.220.1870.02713.58
5.3.210.1790.02513.73
5.3.200.1800.02713.64
5.3.190.1820.02313.68
5.3.180.1740.02013.75
5.3.170.2230.02213.90
5.3.160.1940.02413.83
5.3.150.1800.02413.77
5.3.140.1900.02313.73
5.3.130.1920.02513.79
5.3.120.1800.02513.75
5.3.110.1730.02313.85
5.3.100.1880.02413.47
5.3.90.1630.02013.47
5.3.80.1890.01713.49
5.3.70.1720.02213.40
5.3.60.1820.02313.47
5.3.50.2040.02613.41
5.3.40.2150.02213.50
5.3.30.2120.02313.34
5.3.20.1850.02013.26
5.3.10.1970.01713.21
5.3.00.2050.01713.20
5.2.170.3600.03011.15
5.2.160.3670.02710.97
5.2.150.3600.02711.14
5.2.140.3770.03311.11
5.2.130.3700.03011.05
5.2.120.3570.03010.94
5.2.110.3600.03311.04
5.2.100.3300.02711.13
5.2.90.3630.02711.05
5.2.80.3630.02311.05
5.2.70.3370.03011.07
5.2.60.3230.03011.02
5.2.50.3230.02710.97
5.2.40.2600.02710.95
5.2.30.2200.03310.87
5.2.20.2300.02311.10
5.2.10.2730.02710.89
5.2.00.0470.03710.70
5.1.60.0000.0339.96
5.1.50.0070.0509.93
5.1.40.0030.0509.94
5.1.30.1600.03010.29
5.1.20.2300.02010.20
5.1.10.2470.03010.01
5.1.00.2870.02710.05
5.0.50.1500.0208.48
5.0.40.1370.0208.44
5.0.30.1400.0278.16
5.0.20.1400.0208.28
5.0.10.1570.0208.13
5.0.00.1400.0277.99
4.4.90.1370.0175.80
4.4.80.1330.0175.76
4.4.70.1200.0175.75
4.4.60.1430.0175.76
4.4.50.1570.0175.80
4.4.40.0000.0305.79
4.4.30.0000.0235.89
4.4.20.1370.0175.83
4.4.10.1600.0175.85
4.4.00.1700.0305.80
4.3.110.1630.0205.73
4.3.100.1700.0175.84
4.3.90.1400.0175.79
4.3.80.1470.0235.72
4.3.70.1630.0105.75
4.3.60.1670.0205.78
4.3.50.1700.0135.70
4.3.40.1370.0235.66
4.3.30.0830.0234.91
4.3.20.0870.0204.91
4.3.10.0800.0204.91
4.3.00.0830.0204.91

preferences:
63.06 ms | 400 KiB | 5 Q