3v4l.org

run code in 300+ PHP versions simultaneously
<?php //this seems to work as if there is 2 variables both a protected static and a protected non-static class foo { protected static $myvar = 999; //Uncommenting below leads to a Cannot redeclare foo::$myvar //public $myvar = 77; //Normal non-static Instance Functions public function __construct(){} public function instancePrintVar(){ echo __FUNCTION__.' '.$this->myvar; } public function instanceSetVar($v){ $this->myvar = $v; } //Static functions public static function staticPrintVar(){ echo __FUNCTION__.' '.self::$myvar; } public static function staticSetVar($v){ self::$myvar = $v; } } function nl(){ echo "\n"; } foo::staticPrintVar(); nl(); $foo = new foo(); $foo->instanceSetVar(3); $foo->instancePrintVar(); nl(); foo::staticPrintVar(); nl(); $foo::staticPrintVar(); nl(); foo::staticSetVar(888); foo::staticPrintVar(); $foo->instancePrintVar(); echo "Conclusion: when using \$this-> to change the value, it adds another non-static version rather than changing the static version";

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.0040.01116.75
8.3.50.0100.00921.86
8.3.40.0110.00718.98
8.3.30.0150.00019.09
8.3.20.0040.00420.29
8.3.10.0000.00823.70
8.3.00.0070.00317.71
8.2.180.0150.00016.88
8.2.170.0110.00422.96
8.2.160.0090.00920.52
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0140.00026.16
8.2.120.0040.00422.10
8.2.110.0030.00620.47
8.2.100.0090.00317.91
8.2.90.0000.00819.10
8.2.80.0000.00817.97
8.2.70.0000.00917.50
8.2.60.0120.00017.93
8.2.50.0040.00418.07
8.2.40.0040.00417.99
8.2.30.0050.00217.97
8.2.20.0080.00017.63
8.2.10.0030.00517.63
8.2.00.0030.00517.59
8.1.280.0130.00925.92
8.1.270.0000.00822.14
8.1.260.0000.00826.35
8.1.250.0030.00628.09
8.1.240.0000.00922.03
8.1.230.0070.00320.91
8.1.220.0090.00017.74
8.1.210.0080.00018.77
8.1.200.0040.00717.36
8.1.190.0000.00817.63
8.1.180.0040.00418.10
8.1.170.0050.00518.48
8.1.160.0040.00421.91
8.1.150.0040.00418.51
8.1.140.0040.00417.46
8.1.130.0000.00717.78
8.1.120.0030.00317.43
8.1.110.0040.00417.46
8.1.100.0000.00817.45
8.1.90.0040.00417.45
8.1.80.0060.00317.39
8.1.70.0030.00317.37
8.1.60.0030.00617.51
8.1.50.0050.00217.56
8.1.40.0060.00317.50
8.1.30.0040.00417.58
8.1.20.0040.00417.69
8.1.10.0050.00317.67
8.1.00.0050.00317.44
8.0.300.0000.00718.77
8.0.290.0040.00417.30
8.0.280.0030.00318.48
8.0.270.0000.00717.29
8.0.260.0040.00416.80
8.0.250.0000.00717.05
8.0.240.0070.00016.98
8.0.230.0000.00817.04
8.0.220.0070.00016.89
8.0.210.0030.00316.98
8.0.200.0000.00617.12
8.0.190.0000.00816.95
8.0.180.0030.00717.04
8.0.170.0030.00616.98
8.0.160.0040.00417.02
8.0.150.0070.00016.93
8.0.140.0080.00016.84
8.0.130.0000.00713.46
8.0.120.0090.00016.98
8.0.110.0080.00016.79
8.0.100.0050.00316.80
8.0.90.0030.00316.96
8.0.80.0070.00716.87
8.0.70.0000.00816.82
8.0.60.0000.00716.95
8.0.50.0040.00416.90
8.0.30.0070.01217.24
8.0.20.0040.01317.40
8.0.10.0080.00016.94
8.0.00.0040.01416.79
7.4.330.0000.00515.09
7.4.320.0070.00016.47
7.4.300.0000.00716.54
7.4.290.0030.00316.54
7.4.280.0060.00316.55
7.4.270.0030.00316.46
7.4.260.0020.00516.53
7.4.250.0070.00016.64
7.4.240.0020.00516.62
7.4.230.0030.00316.72
7.4.220.0130.01216.46
7.4.210.0060.01116.68
7.4.200.0030.00316.46
7.4.190.0040.00416.41
7.4.160.0030.01316.66
7.4.150.0100.01017.40
7.4.140.0150.00817.86
7.4.130.0060.00716.54
7.4.120.0100.00716.60
7.4.110.0070.01016.68
7.4.100.0070.01416.69
7.4.90.0070.01116.48
7.4.80.0070.01119.39
7.4.70.0080.01216.59
7.4.60.0150.00016.41
7.4.50.0040.00016.32
7.4.40.0090.00622.77
7.4.30.0100.00616.37
7.4.00.0060.00614.74
7.3.330.0030.00313.54
7.3.320.0030.00313.46
7.3.310.0030.00316.43
7.3.300.0030.00316.45
7.3.290.0070.01416.49
7.3.280.0090.00816.43
7.3.270.0130.01317.40
7.3.260.0090.00916.42
7.3.250.0080.01316.53
7.3.240.0090.01216.64
7.3.230.0130.01016.46
7.3.210.0090.00916.58
7.3.200.0140.00719.39
7.3.190.0110.00716.80
7.3.180.0090.00616.47
7.3.170.0080.00816.63
7.3.160.0120.00816.70
7.3.120.0070.00315.04
7.2.330.0110.01116.84
7.2.320.0070.01016.40
7.2.310.0140.00316.85
7.2.300.0130.00316.75
7.2.290.0030.01316.89
7.2.60.0070.00716.96
7.2.00.0030.01319.23
7.1.200.0090.00315.99
7.1.100.0030.00618.14
7.1.70.0070.00317.07
7.1.60.0140.01019.31
7.1.50.0000.02216.89
7.1.00.0070.08022.34
7.0.200.0090.00616.60
7.0.140.0000.07321.96
7.0.60.0070.07719.94
7.0.50.0100.07317.85
7.0.40.0100.08020.09
7.0.30.0300.07720.10
7.0.20.0270.05020.21
7.0.10.0100.07020.07
7.0.00.0100.04020.09
5.6.280.0000.07721.08
5.6.210.0030.08720.71
5.6.200.0100.08018.29
5.6.190.0070.07020.43
5.6.180.0270.08320.63
5.6.170.0230.04720.44
5.6.160.0070.04020.54
5.6.150.0100.07318.21
5.6.140.0030.04018.17
5.6.130.0030.06718.16
5.6.120.0070.04320.87
5.6.110.0270.06321.02
5.6.100.0100.06320.89
5.6.90.0100.08020.98
5.6.80.0030.06720.54
5.6.70.3930.03320.38
5.5.350.0070.09020.48
5.5.340.0170.07018.05
5.5.330.0130.07320.43
5.5.320.0230.04320.30
5.5.310.0300.07320.31
5.5.300.0130.06018.08
5.5.290.0070.03717.98
5.5.280.0070.08720.88
5.5.270.0030.04020.82
5.5.260.0100.07720.97
5.5.250.0130.07320.79
5.5.240.0070.07320.20
5.4.450.0570.05019.20
5.4.440.0700.05319.47
5.4.430.0530.06019.54
5.4.420.0730.05319.19
5.4.410.0730.06319.34
5.4.400.0770.05319.21
5.4.390.0770.06019.27
5.4.380.0170.06018.86
5.4.370.0330.04318.74
5.4.360.0230.06018.75
5.4.350.0230.06018.54
5.4.340.0200.06018.81
5.4.320.0090.03512.50
5.4.310.0100.04512.50
5.4.300.0070.04212.51
5.4.290.0080.04912.50
5.4.280.0050.03712.40
5.4.270.0080.04412.40
5.4.260.0030.04712.40
5.4.250.0070.03912.40
5.4.240.0080.03712.40
5.4.230.0120.03912.39
5.4.220.0070.04312.39
5.4.210.0080.03612.40
5.4.200.0070.04112.40
5.4.190.0410.07912.37
5.4.180.0210.03912.37
5.4.170.0170.04212.38
5.4.160.0180.04512.38
5.4.150.0430.08412.37
5.4.140.0090.05412.05
5.4.130.0140.04612.05
5.4.120.0160.04312.00
5.4.110.0180.04012.00
5.4.100.0200.04112.00
5.4.90.0120.04712.00
5.4.80.0390.08111.99
5.4.70.0130.04511.99
5.4.60.0160.04212.00
5.4.50.0120.04711.99
5.4.40.0210.04011.98
5.4.30.0160.04911.97
5.4.20.0160.05211.97
5.4.10.0190.04111.97
5.4.00.0150.04311.46
5.3.290.0060.04412.80
5.3.280.0090.03912.71
5.3.270.0230.04212.72
5.3.260.0170.04712.72
5.3.250.0120.04812.72
5.3.240.0160.04412.72
5.3.230.0140.04712.71
5.3.220.0180.04212.68
5.3.210.0310.06212.68
5.3.200.0180.04312.68
5.3.190.0180.04412.68
5.3.180.0260.06412.67
5.3.170.0190.04112.67
5.3.160.0240.04912.68
5.3.150.0170.04712.68
5.3.140.0160.04612.66
5.3.130.0140.04712.65
5.3.120.0210.04212.66
5.3.110.0120.05012.66
5.3.100.0160.04512.11
5.3.90.0160.04312.09
5.3.80.0190.04212.08
5.3.70.0160.04412.08
5.3.60.0160.04312.07
5.3.50.0150.04312.01
5.3.40.0330.11712.01
5.3.30.0150.04311.97
5.3.20.0130.04511.75
5.3.10.0120.04411.72
5.3.00.0150.04311.70
5.2.170.0140.0349.21
5.2.160.0100.0369.21
5.2.150.0130.0369.21
5.2.140.0130.0339.20
5.2.130.0120.0349.16
5.2.120.0100.0379.16
5.2.110.0130.0369.17
5.2.100.0120.0359.18
5.2.90.0120.0349.17
5.2.80.0170.0609.17
5.2.70.0140.0349.16
5.2.60.0070.0429.12
5.2.50.0150.0329.09
5.2.40.0350.0729.07
5.2.30.0150.0319.04
5.2.20.0130.0369.03
5.2.10.0150.0368.93
5.2.00.0130.0338.79
5.1.60.0070.0348.08
5.1.50.0100.0318.07
5.1.40.0120.0278.06
5.1.30.0120.0308.41
5.1.20.0130.0318.43
5.1.10.0120.0328.14
5.1.00.0120.0308.14
5.0.50.0110.0256.64
5.0.40.0100.0226.49
5.0.30.0050.0396.30
5.0.20.0110.0206.27
5.0.10.0150.0166.25
5.0.00.0140.0306.24
4.4.90.0100.0154.78
4.4.80.0060.0194.75
4.4.70.0060.0194.76
4.4.60.0080.0184.75
4.4.50.0070.0174.77
4.4.40.0290.0674.71
4.4.30.0090.0164.76
4.4.20.0050.0204.85
4.4.10.0060.0194.85
4.4.00.0100.0284.75
4.3.110.0060.0184.67
4.3.100.0110.0134.66
4.3.90.0080.0164.63
4.3.80.0060.0284.58
4.3.70.0060.0184.63
4.3.60.0060.0184.63
4.3.50.0080.0164.63
4.3.40.0080.0254.53
4.3.30.0080.0183.30
4.3.20.0070.0183.27
4.3.10.0050.0193.24
4.3.00.0000.0236.23

preferences:
45.18 ms | 401 KiB | 5 Q