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 setPolicySourceDirectives(){ $refl = new ReflectionClass(__CLASS__); $srcPattern = '/.+_SRC$/'; foreach ($refl->getConstants() as $constant => $value){ if (pref_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.0090.00918.11
8.3.50.0150.00621.15
8.3.40.0070.00718.80
8.3.30.0070.00720.29
8.3.20.0070.00020.16
8.3.10.0040.00422.09
8.3.00.0060.00322.33
8.2.180.0120.00916.63
8.2.170.0120.00322.96
8.2.160.0120.00922.04
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00020.56
8.2.110.0070.01022.25
8.2.100.0070.00617.88
8.2.90.0000.00819.21
8.2.80.0000.00919.41
8.2.70.0040.00417.75
8.2.60.0040.00718.03
8.2.50.0080.00018.07
8.2.40.0060.00318.15
8.2.30.0040.00419.40
8.2.20.0030.00517.70
8.2.10.0060.00317.86
8.2.00.0040.00417.76
8.1.280.0100.00725.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00023.77
8.1.230.0030.00719.01
8.1.220.0080.00017.77
8.1.210.0040.00418.77
8.1.200.0070.00317.34
8.1.190.0040.00417.42
8.1.180.0040.00418.10
8.1.170.0000.00818.59
8.1.160.0000.01018.92
8.1.150.0000.00818.68
8.1.140.0040.00417.46
8.1.130.0000.00717.82
8.1.120.0050.00317.41
8.1.110.0000.00817.55
8.1.100.0080.00017.52
8.1.90.0000.00717.50
8.1.80.0050.00317.52
8.1.70.0030.00317.52
8.1.60.0000.00817.54
8.1.50.0080.00017.57
8.1.40.0080.00417.54
8.1.30.0000.00817.68
8.1.20.0040.00417.74
8.1.10.0070.00017.65
8.1.00.0050.00317.55
8.0.300.0070.00018.77
8.0.290.0000.00817.15
8.0.280.0030.00518.54
8.0.270.0030.00317.36
8.0.260.0000.00716.92
8.0.250.0000.00717.00
8.0.240.0060.00517.08
8.0.230.0000.00817.04
8.0.220.0000.00716.89
8.0.210.0030.00316.89
8.0.200.0000.00617.07
8.0.190.0040.00417.13
8.0.180.0000.00716.97
8.0.170.0050.00316.93
8.0.160.0000.00717.02
8.0.150.0000.00716.91
8.0.140.0040.00716.94
8.0.130.0030.00313.46
8.0.120.0050.00316.91
8.0.110.0040.00416.89
8.0.100.0070.00016.86
8.0.90.0040.00416.92
8.0.80.0030.01416.95
8.0.70.0040.00416.87
8.0.60.0040.00416.88
8.0.50.0070.00017.06
8.0.30.0130.00617.05
8.0.20.0050.01317.40
8.0.10.0080.00017.19
8.0.00.0080.01216.87
7.4.330.0050.00016.73
7.4.320.0000.00616.59
7.4.300.0000.00616.65
7.4.290.0000.00816.63
7.4.280.0030.00316.49
7.4.270.0030.00316.65
7.4.260.0030.00313.34
7.4.250.0030.00516.39
7.4.240.0060.00216.66
7.4.230.0000.00716.54
7.4.220.0070.01116.50
7.4.210.0060.00916.67
7.4.200.0040.00416.62
7.4.190.0000.00716.50
7.4.160.0080.00816.68
7.4.150.0120.00617.40
7.4.140.0080.01017.86
7.4.130.0120.00516.57
7.4.120.0110.00716.60
7.4.110.0060.01016.58
7.4.100.0070.01116.71
7.4.90.0100.00616.63
7.4.80.0090.01219.39
7.4.70.0090.01016.57
7.4.60.0070.01016.51
7.4.50.0030.00616.62
7.4.40.0070.01322.77
7.4.30.0110.00816.61
7.4.00.0060.00914.85
7.3.330.0000.00513.52
7.3.320.0000.00613.29
7.3.310.0000.00716.52
7.3.300.0030.00316.57
7.3.290.0080.00816.49
7.3.280.0080.00916.49
7.3.270.0030.01317.40
7.3.260.0040.01518.24
7.3.250.0120.00916.52
7.3.240.0080.00816.48
7.3.230.0130.01016.55
7.3.210.0100.00616.48
7.3.200.0130.00619.39
7.3.190.0080.01216.71
7.3.180.0130.00616.53
7.3.170.0120.00316.59
7.3.160.0090.01216.54
7.3.120.0090.00615.18
7.2.330.0140.00916.65
7.2.320.0030.01516.93
7.2.310.0120.00616.63
7.2.300.0100.01316.46
7.2.290.0140.00716.89
7.2.60.0060.00917.15
7.2.00.0130.00019.45
7.1.200.0110.00315.46
7.1.100.0030.00618.23
7.1.70.0090.00017.27
7.1.60.0030.01016.90
7.1.50.0000.01116.91
7.1.40.0040.00816.72
7.1.30.0110.00416.79
7.1.20.0040.00816.72
7.1.10.0000.00916.72
7.1.00.0000.00716.81
7.0.200.0000.00916.92
7.0.190.0030.00316.72
7.0.180.0050.00516.72
7.0.170.0040.00416.72
7.0.160.0000.01116.72
7.0.150.0000.00816.72
7.0.140.0070.00316.72
7.0.130.0050.00316.72
7.0.120.0030.00516.72
7.0.110.0000.01116.72
7.0.100.0020.00516.72
7.0.90.0030.00716.72
7.0.80.0000.00816.72
7.0.70.0000.00816.72
7.0.60.0040.00416.72
7.0.50.0000.00816.72
7.0.40.0000.00816.72
7.0.30.0000.00716.72
7.0.20.0000.01016.72
7.0.10.0030.01316.72
7.0.00.0000.00816.72
5.6.300.0100.03320.91
5.6.290.0030.04320.88
5.6.280.0030.04521.00
5.6.270.0030.04121.00
5.6.260.0000.04421.06
5.6.250.0030.07020.81
5.6.240.0000.04820.89
5.6.230.0030.04720.82
5.6.220.0030.04620.85
5.6.210.0030.04121.08
5.6.200.0070.04020.89
5.6.190.0030.04620.72
5.6.180.0000.05120.99
5.6.170.0000.04220.97
5.6.160.0000.04420.89
5.6.150.0030.04620.89
5.6.140.0070.04221.04
5.6.130.0030.05820.76
5.6.120.0000.05620.81
5.6.110.0030.04420.83
5.6.100.0030.04220.76
5.6.90.0030.04220.71
5.6.80.0000.04320.27
5.6.70.0030.03820.13
5.6.60.0170.04420.24
5.6.50.0030.03820.40
5.6.40.0100.07720.20
5.6.30.0100.03720.14
5.6.20.0000.04220.40
5.6.10.0030.03820.30
5.6.00.0030.05020.41
5.5.380.0030.04017.57
5.5.370.0100.03317.63
5.5.360.0070.03717.63
5.5.350.0000.05317.64
5.5.340.0030.04318.13
5.5.330.0100.03518.18
5.5.320.0030.04418.09
5.5.310.0000.04718.09
5.5.300.0000.04618.17
5.5.290.0060.05218.09
5.5.280.0000.04817.85
5.5.270.0130.03017.83
5.5.260.0030.04318.17
5.5.250.0100.05517.90
5.5.240.0030.04017.48
5.5.230.0000.04617.41
5.5.220.0060.03817.09
5.5.210.0000.04717.55
5.5.200.0030.04517.09
5.5.190.0000.04317.47
5.5.180.0030.03917.48
5.5.160.0100.03217.48
5.5.150.0070.04817.52
5.5.140.0030.03817.38
5.5.130.0040.04217.39
5.5.120.0000.04217.44
5.5.110.0000.05817.05
5.5.100.0070.03417.38
5.5.90.0000.04917.37
5.5.80.0090.03117.11
5.5.70.0100.06317.08
5.5.60.0000.04117.33
5.5.50.0040.04317.37
5.5.40.0030.04017.28
5.5.30.0100.03317.35
5.5.20.0000.04117.32
5.5.10.0100.03017.35
5.5.00.0030.07317.29
5.4.450.0030.04419.49
5.4.440.0070.06319.21
5.4.430.0030.05019.38
5.4.420.0160.03919.38
5.4.410.0030.06619.13
5.4.400.0030.03818.90
5.4.390.0070.03718.95
5.4.380.0070.04219.16
5.4.370.0030.07219.00
5.4.360.0030.04418.89
5.4.350.0000.04819.09
5.4.340.0000.04019.09
5.4.320.0070.07618.93
5.4.310.0070.03519.21
5.4.300.0030.06619.20
5.4.290.0030.03818.98
5.4.280.0000.04219.06
5.4.270.0030.04018.97
5.4.260.0000.06219.02
5.4.250.0030.03518.88
5.4.240.0030.08119.03
5.4.230.0030.05218.93
5.4.220.0030.04119.15
5.4.210.0000.04118.96
5.4.200.0030.03719.16
5.4.190.0030.04019.14
5.4.180.0040.04218.98
5.4.170.0030.05818.91
5.4.160.0030.04818.91
5.4.150.0000.07619.17
5.4.140.0040.03616.73
5.4.130.0000.03816.72
5.4.120.0040.04916.72
5.4.110.0060.04116.75
5.4.100.0000.04116.72
5.4.90.0040.03916.78
5.4.80.0030.03816.73
5.4.70.0030.03616.72
5.4.60.0000.03816.72
5.4.50.0000.04116.72
5.4.40.0070.03716.72
5.4.30.0130.03216.72
5.4.20.0030.04016.72
5.4.10.0000.03816.72
5.4.00.0030.03716.72
5.3.290.0030.04416.72
5.3.280.0030.04316.72
5.3.270.0000.04616.72
5.3.260.0000.09216.72
5.3.250.0000.04516.72
5.3.240.0000.04016.72
5.3.230.0070.05416.72
5.3.220.0030.03616.72
5.3.210.0070.04916.72
5.3.200.0100.04216.72
5.3.190.0000.04516.72
5.3.180.0200.03616.72
5.3.170.0070.05616.72
5.3.160.0070.03216.72
5.3.150.0000.04216.72
5.3.140.0000.05016.72
5.3.130.0030.03616.72
5.3.120.0000.04216.72
5.3.110.0000.04216.72
5.3.100.0140.03716.72
5.3.90.0030.04216.72
5.3.80.0000.05616.72
5.3.70.0000.05216.72
5.3.60.0070.03916.72
5.3.50.0030.03616.72
5.3.40.0030.04216.72
5.3.30.0060.03916.72
5.3.20.0060.03216.72
5.3.10.0110.02816.72
5.3.00.0000.03816.72
5.2.170.0060.02616.72
5.2.160.0030.03216.72
5.2.150.0070.04916.72
5.2.140.0100.02316.72
5.2.130.0030.02716.72
5.2.120.0030.02816.72
5.2.110.0070.02416.72
5.2.100.0060.03716.72
5.2.90.0030.03116.72
5.2.80.0030.04116.72
5.2.70.0030.03016.72
5.2.60.0030.03116.72
5.2.50.0000.04416.72
5.2.40.0070.03316.72
5.2.30.0160.03316.72
5.2.20.0070.02416.72
5.2.10.0030.02716.72
5.2.00.0030.04616.72
5.1.60.0000.05316.72
5.1.50.0000.02916.72
5.1.40.0000.02716.72
5.1.30.0000.02916.72
5.1.20.0040.02616.72
5.1.10.0060.03216.72
5.1.00.0030.02616.72
5.0.50.0000.03116.72
5.0.40.0000.02916.72
5.0.30.0000.05916.72
5.0.20.0030.02716.72
5.0.10.0000.02316.72
5.0.00.0000.03216.72
4.4.90.0070.01316.72
4.4.80.0060.01816.72
4.4.70.0030.01616.72
4.4.60.0000.02016.72
4.4.50.0030.01916.72
4.4.40.0060.02216.72
4.4.30.0040.01816.72
4.4.20.0000.02016.72
4.4.10.0030.01316.72
4.4.00.0000.03716.72
4.3.110.0030.01316.72
4.3.100.0030.02016.72
4.3.90.0030.01616.72
4.3.80.0030.05216.72
4.3.70.0030.01316.72
4.3.60.0000.01616.72
4.3.50.0000.01716.72
4.3.40.0030.03216.72
4.3.30.0000.03016.72
4.3.20.0000.01916.72
4.3.10.0000.03416.72
4.3.00.0000.01616.72

preferences:
44.76 ms | 401 KiB | 5 Q