3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ancestor { public $publicVar = "ancestor's public var\n"; static $staticVar = "ancestor's static var\n"; function publicMethod(){ echo "ancestor's publicMethod "; // is $this is set up if(isset($this)){ echo "is in object context\n"; }else{ echo "is in static context\n"; } } static function staticMethod(){ echo "ancestor's staticMethod "; // is $this is set up if(isset($this)){ echo "in object context\n"; }else{ echo "in static context\n"; } } } class Descendant extends Ancestor { public $publicVar = "descendant's public var\n"; static $staticVar = "descendant's static var\n"; function publicMethod(){ echo "descendant's publicMethod "; // is $this is set up if(isset($this)){ echo "in object context\n"; }else{ echo "in static context\n"; } } static function staticMethod(){ echo "descendant's staticMethod "; // is $this is set up if(isset($this)){ echo "in object context\n"; }else{ echo "in static context\n"; } } function callToPropertiesFromPublicContext(){ echo $this->publicVar; // descendant's public var //echo $this->staticVar; // "" + notice: Undefined property: Descendant::$staticVar //echo $this::$publicVar; // fatal error: Access to undeclared static property: Descendant::$publicVar echo $this::$staticVar; echo Descendant::$publicVar; echo Descendant::$staticVar; } static function callToPropertiesFromStaticContext(){ echo Descendant::$publicVar; echo Descendant::$staticVar; } } $ancestor = new Ancestor(); $descendant = new Descendant(); echo "\n1. From Outside Of An Instance/Class:\n"; echo "\n----- 1.1 access to properties -----\n"; echo $descendant->publicVar; // descendant's public var //echo $descendant->staticVar; // "" + notice: Undefined property: Descendant::$staticVar //echo $descendant::$publicVar; // fatal error: Access to undeclared static property: Descendant::$publicVar echo $descendant::$staticVar; // descendant's static var //echo Descendant::$publicVar; // fatal error: Access to undeclared static property echo Descendant::$staticVar; // descendant's static var echo "\n----- 1.2 access to methods -----\n"; $descendant->publicMethod(); // descendant's publicMethod in object context $descendant->staticMethod(); // descendant's staticMethod in static context $descendant::publicMethod(); // descendant's publicMethod in static context $descendant::staticMethod(); // descendant's staticMethod in static context Descendant::publicMethod(); // descendant's publicMethod in static context Descendant::staticMethod(); // descendant's staticMethod in static context echo "\n2. From Inside Of An Instance/Class:\n"; echo "\n----- 2.1 access to properties from public context -----\n"; $descendant->callToPropertiesFromPublicContext(); echo "\n----- 2.1 access to properties from static context -----\n"; $descendant->callToPropertiesFromStaticContext();

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.40.0130.00318.78
8.3.30.0140.00018.68
8.3.20.0070.00020.19
8.3.10.0050.00321.77
8.3.00.0000.00819.44
8.2.170.0070.00722.96
8.2.160.0030.01020.53
8.2.150.0080.00024.18
8.2.140.0070.01324.66
8.2.130.0040.00426.16
8.2.120.0030.00617.38
8.2.110.0070.00319.30
8.2.100.0060.00617.84
8.2.90.0000.00817.75
8.2.80.0000.00817.97
8.2.70.0000.00817.55
8.2.60.0000.00817.93
8.2.50.0000.00818.10
8.2.40.0030.00620.26
8.2.30.0030.00619.72
8.2.20.0040.00417.75
8.2.10.0040.00418.02
8.2.00.0060.00318.01
8.1.270.0070.00720.32
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0080.00023.98
8.1.230.0040.00719.16
8.1.220.0030.00617.74
8.1.210.0050.00318.77
8.1.200.0070.00317.35
8.1.190.0000.00917.35
8.1.180.0000.00918.10
8.1.170.0040.00418.53
8.1.160.0040.00422.04
8.1.150.0040.00418.75
8.1.140.0030.00517.36
8.1.130.0030.00317.57
8.1.120.0080.00017.45
8.1.110.0050.00317.42
8.1.100.0040.00417.32
8.1.90.0040.00417.43
8.1.80.0000.00817.46
8.1.70.0030.00517.42
8.1.60.0040.00417.48
8.1.50.0050.00317.46
8.1.40.0080.00017.51
8.1.30.0050.00317.60
8.1.20.0000.00817.50
8.1.10.0040.00417.61
8.1.00.0030.00517.43
8.0.300.0040.00419.63
8.0.290.0000.00916.75
8.0.280.0080.00018.46
8.0.270.0000.00717.26
8.0.260.0000.00717.12
8.0.250.0040.00417.03
8.0.240.0040.00416.90
8.0.230.0030.00316.86
8.0.220.0040.00416.92
8.0.210.0040.00416.77
8.0.200.0040.00417.01
8.0.190.0000.00816.94
8.0.180.0060.00316.90
8.0.170.0050.00216.93
8.0.160.0040.00416.89
8.0.150.0000.00716.82
8.0.140.0000.00716.77
8.0.130.0040.00413.38
8.0.120.0040.00416.86
8.0.110.0070.00016.89
8.0.100.0040.00416.84
8.0.90.0000.00716.89
8.0.80.0100.01016.83
8.0.70.0040.00416.78
8.0.60.0070.00016.96
8.0.50.0000.00816.94
8.0.30.0120.00817.12
8.0.20.0050.01417.40
8.0.10.0000.00816.97
8.0.00.0050.01316.79
7.4.330.0000.00515.09
7.4.320.0000.00716.53
7.4.300.0030.00316.44
7.4.290.0030.00316.59
7.4.280.0030.00516.46
7.4.270.0000.00716.54
7.4.260.0000.00716.52
7.4.250.0050.00216.54
7.4.240.0040.00416.48
7.4.230.0030.00316.43
7.4.220.0070.01016.46
7.4.210.0040.01016.59
7.4.200.0020.00516.40
7.4.160.0030.01316.40
7.4.150.0040.01417.40
7.4.140.0110.01117.86
7.4.130.0130.00416.55
7.4.120.0110.00816.59
7.4.110.0080.01116.63
7.4.100.0070.01016.58
7.4.90.0060.01216.57
7.4.80.0100.00719.39
7.4.70.0150.00316.59
7.4.60.0070.01016.50
7.4.50.0000.00816.48
7.4.40.0070.01016.36
7.4.30.0130.00616.37
7.4.00.0040.01215.08
7.3.330.0000.00613.22
7.3.320.0000.00513.30
7.3.310.0000.00816.46
7.3.300.0070.00016.40
7.3.290.0000.00716.30
7.3.280.0110.00816.47
7.3.270.0170.00017.40
7.3.260.0170.00316.38
7.3.250.0080.00916.48
7.3.240.0030.01416.50
7.3.230.0120.00916.65
7.3.210.0110.00816.34
7.3.200.0100.00716.50
7.3.190.0050.01116.53
7.3.180.0060.00916.50
7.3.170.0000.01716.57
7.3.160.0150.00616.61
7.2.330.0030.01316.82
7.2.320.0070.01116.80
7.2.310.0170.00016.73
7.2.300.0050.01116.73
7.2.290.0030.01416.82
7.2.60.0120.00316.95
7.2.00.0060.00619.33
7.1.200.0060.00615.70
7.1.100.0030.00918.09
7.1.70.0000.00817.16
7.1.60.0140.01020.03
7.1.50.0100.01016.88
7.1.00.0100.07022.35
7.0.200.0050.00216.78
7.0.60.0000.04319.97
7.0.50.0030.08317.75
7.0.40.0130.05320.05
7.0.30.0330.06320.32
7.0.20.0230.08320.24
7.0.10.0030.07720.30
7.0.00.0200.07320.23
5.6.280.0100.06720.93
5.6.210.0130.07320.63
5.6.200.0070.03718.13
5.6.190.0030.08720.58
5.6.180.0730.07020.68
5.6.170.0330.06020.39
5.6.160.0030.05720.46
5.6.150.0100.07718.27
5.6.140.0000.06318.28
5.6.130.0030.05018.27
5.6.120.0200.06321.01
5.6.110.0070.07720.99
5.6.100.0170.07720.90
5.6.90.0000.08321.13
5.6.80.0070.05320.52
5.5.350.0030.07020.32
5.5.340.0100.05717.93
5.5.330.0100.08020.40
5.5.320.1500.04720.20
5.5.310.0170.04320.27
5.5.300.0130.07718.03
5.5.290.0070.08018.01
5.5.280.0030.04720.85
5.5.270.0070.07020.93
5.5.260.0070.05020.99
5.5.250.0030.07020.59
5.5.240.0070.07320.20
5.4.450.0300.06019.57
5.4.440.0370.05719.58
5.4.430.0530.04019.69
5.4.420.0430.05019.15
5.4.410.0400.06319.46
5.4.400.0500.03718.93
5.4.390.0530.06019.29
5.4.380.0530.04319.09
5.4.370.0630.05319.28
5.4.360.0500.05019.24
5.4.350.0470.04719.25
5.4.340.0430.06319.06
5.4.320.0500.06018.93
5.4.310.0470.05019.14
5.4.300.0400.06018.93
5.4.290.0370.05018.82
5.4.280.0400.06019.26
5.4.270.0300.05718.79
5.4.260.0430.04319.06
5.4.250.0530.06019.07
5.4.240.0370.05019.05
5.4.230.0330.05319.13
5.4.220.0370.05019.05
5.4.210.0300.05718.84
5.4.200.0400.04719.36
5.4.190.0300.05718.82
5.4.180.0530.05719.25
5.4.170.0400.05319.09
5.4.160.0470.06019.05
5.4.150.0430.05019.23
5.4.140.0370.05016.49
5.4.130.0530.04716.35
5.4.120.0570.06016.37
5.4.110.0400.05316.33
5.4.100.0400.04016.63
5.4.90.0430.04316.67
5.4.80.0430.04016.55
5.4.70.0130.03716.59
5.4.60.0100.04016.24
5.4.50.0100.06716.34
5.4.40.0200.03716.22
5.4.30.0030.05716.55
5.4.20.0270.06716.23
5.4.10.0200.03716.54

preferences:
43.95 ms | 400 KiB | 5 Q