3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { private $basePrivate = 'private in base class'; protected $baseProtected = 'protected in base class'; public $basePublic = 'public in base class'; public function baseExample() { // We *can't* access $this->doesNotExist because it doesn't exist. echo $this->doesNotExist; //ERROR // We *can* access the following: echo __LINE__ . ': ' . $this->basePrivate . "\n"; //OK echo __LINE__ . ': ' . $this->baseProtected . "\n"; //OK echo __LINE__ . ': ' . $this->basePublic . "\n"; //OK } } class Child extends Base { private $childPrivate = 'private in child class'; protected $childProtected = 'protected in child class'; public $childPublic = 'public in child class'; public function childExample() { // We can't access $this->basePrivate because the base class // declared it as private (this is the what private means) echo $this->basePrivate; //ERROR // We can't access $this->doesNotExist because it doesn't exist. echo $this->doesNotExist; //ERROR // We *can* access the following: echo __LINE__ . ': ' . $this->baseProtected . "\n"; //OK echo __LINE__ . ': ' . $this->basePublic . "\n"; //OK echo __LINE__ . ': ' . $this->childPrivate . "\n"; //OK echo __LINE__ . ': ' . $this->childProtected . "\n"; //OK echo __LINE__ . ': ' . $this->childPublic . "\n"; //OK } } // Now we'll create instances of these classes. Since we're now outside of the // classes (i.e. we're using instances of the classes and not in the actual code of the class) // we can now only access public properties. $base = new Base; $child = new Child; // Let's run our demo methods to see the results echo $base->baseExample(); echo $child->childExample(); // Outside the class, we *can't* access the following: echo $base->doesNotExist; //ERROR echo $base->basePrivate; //ERROR echo $base->baseProtected; //ERROR echo $child->doesNotExist; //ERROR echo $child->basePrivate; //ERROR echo $child->baseProtected; //ERROR echo $child->childPrivate; //ERROR echo $child->childProtected; //ERROR // Outside the class, we *can* access public properties echo __LINE__ . ': ' . $base->basePublic . "\n"; //OK echo __LINE__ . ': ' . $child->basePublic . "\n"; //OK echo __LINE__ . ': ' . $child->childPublic . "\n"; //OK

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.0150.00618.40
8.3.50.0110.01121.08
8.3.40.0000.01518.97
8.3.30.0150.00618.73
8.3.20.0000.00820.25
8.3.10.0080.00023.56
8.3.00.0080.00022.51
8.2.180.0110.00718.14
8.2.170.0110.00422.96
8.2.160.0070.00722.26
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0030.00617.75
8.2.110.0100.00020.99
8.2.100.0060.00617.91
8.2.90.0030.00519.23
8.2.80.0050.00317.97
8.2.70.0000.00817.75
8.2.60.0060.00317.80
8.2.50.0080.00018.07
8.2.40.0000.00821.09
8.2.30.0060.00319.72
8.2.20.0000.00817.77
8.2.10.0000.00818.09
8.2.00.0070.00018.09
8.1.280.0100.01025.92
8.1.270.0090.00620.32
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00021.50
8.1.230.0080.00417.42
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0000.01117.35
8.1.190.0040.00417.23
8.1.180.0060.00318.10
8.1.170.0040.00418.69
8.1.160.0000.00822.05
8.1.150.0050.00318.91
8.1.140.0000.00717.42
8.1.130.0000.00817.53
8.1.120.0000.00717.45
8.1.110.0000.00717.39
8.1.100.0030.00517.39
8.1.90.0000.00717.42
8.1.80.0070.00017.48
8.1.70.0030.00317.31
8.1.60.0000.00817.52
8.1.50.0050.00317.58
8.1.40.0050.00317.57
8.1.30.0040.00417.65
8.1.20.0030.00617.71
8.1.10.0000.00817.62
8.1.00.0000.00817.54
8.0.300.0000.00718.77
8.0.290.0090.00016.88
8.0.280.0030.00318.54
8.0.270.0080.00017.30
8.0.260.0050.00316.92
8.0.250.0000.00816.92
8.0.240.0000.00817.13
8.0.230.0000.00717.04
8.0.220.0030.00316.89
8.0.210.0000.00716.86
8.0.200.0030.00317.06
8.0.190.0020.00816.94
8.0.180.0000.00717.05
8.0.170.0040.00417.04
8.0.160.0050.00317.02
8.0.150.0030.00316.91
8.0.140.0050.00216.85
8.0.130.0030.00313.38
8.0.120.0040.00416.98
8.0.110.0040.00416.86
8.0.100.0050.00217.04
8.0.90.0000.00816.79
8.0.80.0160.00016.95
8.0.70.0040.00416.98
8.0.60.0040.00416.73
8.0.50.0040.00416.84
8.0.30.0040.01517.11
8.0.20.0130.00617.40
8.0.10.0040.00417.08
8.0.00.0100.00716.76
7.4.330.0000.00715.08
7.4.320.0030.00316.53
7.4.300.0000.00716.64
7.4.290.0070.00016.55
7.4.280.0030.00516.54
7.4.270.0070.00016.67
7.4.260.0000.00716.43
7.4.250.0030.00516.60
7.4.240.0060.00216.50
7.4.230.0000.00716.65
7.4.220.0140.01316.48
7.4.210.0080.00716.58
7.4.200.0040.00416.71
7.4.160.0040.01216.56
7.4.150.0120.01217.40
7.4.140.0150.00917.86
7.4.130.0110.00816.59
7.4.120.0120.00616.56
7.4.110.0120.00616.65
7.4.100.0150.00316.30
7.4.90.0060.01616.47
7.4.80.0090.01019.39
7.4.70.0050.01016.65
7.4.60.0090.00616.52
7.4.50.0040.00416.51
7.4.40.0110.01116.42
7.4.30.0070.01416.60
7.4.10.0100.01014.68
7.4.00.0080.01015.11
7.3.330.0070.00013.37
7.3.320.0050.00313.30
7.3.310.0070.00016.25
7.3.300.0060.00016.39
7.3.290.0000.00716.29
7.3.280.0120.00416.31
7.3.270.0120.00617.40
7.3.260.0060.01616.45
7.3.250.0130.00616.38
7.3.240.0100.00716.46
7.3.230.0110.00816.43
7.3.210.0120.00916.41
7.3.200.0080.00819.39
7.3.190.0090.00616.46
7.3.180.0030.01816.60
7.3.170.0070.01016.44
7.3.160.0160.00616.35
7.3.130.0070.01314.80
7.3.120.0090.01014.81
7.3.110.0110.00814.80
7.3.100.0100.00514.71
7.3.90.0060.01014.75
7.3.80.0020.01214.93
7.3.70.0060.00814.74
7.3.60.0020.01214.70
7.3.50.0070.00814.92
7.3.40.0090.00714.73
7.3.30.0070.00614.81
7.3.20.0100.00716.68
7.3.10.0070.00716.59
7.3.00.0070.01016.68
7.2.330.0100.01016.73
7.2.320.0060.01016.59
7.2.310.0140.00316.46
7.2.300.0120.00816.83
7.2.290.0130.00316.82
7.2.260.0150.00414.89
7.2.250.0020.01714.96
7.2.240.0080.00815.24
7.2.230.0050.01214.89
7.2.220.0050.01215.13
7.2.210.0020.01315.23
7.2.200.0020.01415.11
7.2.190.0080.00815.07
7.2.180.0060.01115.01
7.2.170.0070.00615.03
7.2.160.0090.00515.09
7.2.150.0040.00916.97
7.2.140.0070.00716.87
7.2.130.0030.00717.05
7.2.120.0030.00916.88
7.2.110.0090.00616.80
7.2.100.0050.01016.79
7.2.90.0130.00316.99
7.2.80.0040.01116.90
7.2.70.0100.00716.97
7.2.60.0030.01016.86
7.2.50.0040.01217.00
7.2.40.0050.00617.06
7.2.30.0070.00917.07
7.2.20.0090.00716.87
7.2.10.0050.00916.98
7.2.00.0070.00717.65
7.1.330.0070.01015.74
7.1.320.0090.00815.78
7.1.310.0050.00815.67
7.1.300.0030.01215.63
7.1.290.0050.00815.74
7.1.280.0060.00415.81
7.1.270.0140.00215.85
7.1.260.0090.00515.93
7.1.250.0030.00515.88
7.1.240.0070.01215.78
7.1.230.0080.00815.74
7.1.220.0030.01015.73
7.1.210.0050.00815.74
7.1.200.0050.00615.76
7.1.190.0060.00615.78
7.1.180.0070.00815.78
7.1.170.0040.00715.87
7.1.160.0070.00915.76
7.1.150.0080.00715.68
7.1.140.0060.00915.84
7.1.130.0060.00815.74
7.1.120.0080.00615.59
7.1.110.0060.00515.76
7.1.100.0080.00616.52
7.1.90.0050.01015.79
7.1.80.0050.00615.68
7.1.70.0040.00916.27
7.1.60.0070.01216.80
7.1.50.0070.00716.16
7.1.40.0020.01115.79
7.1.30.0050.00915.63
7.1.20.0070.00815.78
7.1.10.0050.00915.80
7.1.00.0050.02917.88
7.0.330.0080.00515.34
7.0.320.0070.00715.49
7.0.310.0100.00415.40
7.0.300.0060.00715.41
7.0.290.0040.01115.26
7.0.280.0030.01215.27
7.0.270.0030.01215.36
7.0.260.0100.00415.50
7.0.250.0040.01015.28
7.0.240.0100.00215.40
7.0.230.0070.00715.51
7.0.220.0070.00715.49
7.0.210.0100.00615.51
7.0.200.0050.00815.86
7.0.190.0030.00815.29
7.0.180.0050.00915.60
7.0.170.0090.00215.39
7.0.160.0050.00915.40
7.0.150.0050.01215.45
7.0.140.0080.00415.34
7.0.130.0060.00615.39
7.0.120.0050.00815.55
7.0.110.0050.00815.53
7.0.100.0080.00615.51
7.0.90.0060.00915.37
7.0.80.0020.01215.34
7.0.70.0000.01315.46
7.0.60.0060.01916.98
7.0.50.0070.03016.28
7.0.40.0060.03315.55
7.0.30.0120.02815.72
7.0.20.0160.03115.51
7.0.10.0080.01715.78
7.0.00.0040.02215.73
5.6.400.0060.00814.39
5.6.390.0110.00514.47
5.6.380.0050.00514.45
5.6.370.0100.00314.39
5.6.360.0050.00714.21
5.6.350.0080.00514.26
5.6.340.0070.00514.36
5.6.330.0050.01014.43
5.6.320.0060.00314.43
5.6.310.0050.01014.07
5.6.300.0050.00914.44
5.6.290.0080.00214.41
5.6.280.0020.02016.64
5.6.270.0110.00514.35
5.6.260.0110.00414.19
5.6.250.0060.00714.37
5.6.240.0050.00814.26
5.6.230.0090.00814.49
5.6.220.0060.01014.16
5.6.210.0040.01916.46
5.6.200.0060.03215.61
5.6.190.0040.03416.37
5.6.180.1310.01816.45
5.6.170.0160.01916.37
5.6.160.0060.03416.39
5.6.150.0040.02415.54
5.6.140.0040.01915.59
5.6.130.0050.01815.68
5.6.120.0040.01916.49
5.6.110.0090.02916.64
5.6.100.0060.02916.52
5.6.90.0050.03416.71
5.6.80.0070.03116.27
5.6.70.1290.01916.19
5.6.60.0070.00314.19
5.6.50.0060.00514.27
5.6.40.0090.00614.26
5.6.30.0050.00814.33
5.6.20.0000.01214.31
5.6.10.0030.01114.18
5.6.00.0070.00514.25
5.5.380.0110.00514.14
5.5.370.0050.01014.36
5.5.360.0080.00514.09
5.5.350.0070.01916.35
5.5.340.0050.01815.59
5.5.330.0060.03316.27
5.5.320.1070.01816.18
5.5.310.0180.02416.22
5.5.300.0050.01915.50
5.5.290.0070.01815.54
5.5.280.0090.03116.47
5.5.270.0050.03416.39
5.5.260.0050.02116.49
5.5.250.0050.01916.32
5.5.240.0130.01616.22
5.5.230.0000.01214.31
5.5.220.0020.01114.23
5.5.210.0050.00914.42
5.5.200.0070.00814.20
5.5.190.0110.00014.17
5.5.180.0070.00814.18
5.5.170.0090.00514.17
5.5.160.0070.00614.16
5.5.150.0030.00814.27
5.5.140.0050.00414.27
5.5.130.0030.01014.16
5.5.120.0050.00814.16
5.5.110.0080.00513.95
5.5.100.0050.00814.16
5.5.90.0030.01013.99
5.5.80.0110.00314.00
5.5.70.0070.00814.29
5.5.60.0100.00214.26
5.5.50.0050.00714.14
5.5.40.0060.00814.35
5.5.30.0050.01014.10
5.5.20.0020.01214.12
5.5.10.0090.00614.16
5.5.00.0050.00814.25
5.4.450.0270.02514.36
5.4.440.0220.02214.51
5.4.430.0070.02114.39
5.4.420.0030.02514.46
5.4.410.0260.02814.43
5.4.400.0280.02714.40
5.4.390.0310.02414.46
5.4.380.0370.01814.31
5.4.370.0290.02214.39
5.4.360.0360.01914.30
5.4.350.0340.02814.36
5.4.340.0320.02514.35
5.4.330.0040.00811.98
5.4.320.0350.02414.16
5.4.310.0260.02614.32
5.4.300.0250.02414.36
5.4.290.0270.02714.35
5.4.280.0310.02514.24
5.4.270.0360.01914.28
5.4.260.0380.01714.38
5.4.250.0310.02114.26
5.4.240.0290.02214.36
5.4.230.0290.02514.32
5.4.220.0350.01814.40
5.4.210.0350.02014.35
5.4.200.0290.01813.59
5.4.190.0350.01914.31
5.4.180.0360.02114.25
5.4.170.0320.02114.38
5.4.160.0290.02214.20
5.4.150.0360.02014.43
5.4.140.0290.02213.61
5.4.130.0240.02113.50
5.4.120.0260.02213.42
5.4.110.0350.01413.50
5.4.100.0320.02513.47
5.4.90.0340.01713.35
5.4.80.0280.02013.51
5.4.70.0270.01913.45
5.4.60.0120.01413.40
5.4.50.0030.02013.49
5.4.40.0080.02013.40
5.4.30.0100.02413.40
5.4.20.0150.02313.43
5.4.10.0020.00611.95
5.4.00.0010.00711.97

preferences:
65.65 ms | 401 KiB | 5 Q