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 "this is ancestor's public method\n"; // is $this is set up if(isset($this)){ echo "publicMethod is in object context\n"; }else{ echo "publicMethod is in static context\n"; } } static function staticMethod(){ echo "this is ancestor's static method\n"; // is $this is set up if(isset($this)){ echo "staticMethod is in object context\n"; }else{ echo "staticMethod is 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 "this is descendant's public method\n"; // is $this is set up if(isset($this)){ echo "publicMethod is in object context\n"; }else{ echo "publicMethod is in static context\n"; } } static function staticMethod(){ echo "this is descendant's static method\n"; // is $this is set up if(isset($this)){ echo "staticMethod is in object context\n"; }else{ echo "staticMethod is in static context\n"; } } } $ancestor = new Ancestor(); $descendant = new Descendant(); // From Outside Of An Instance/Class: // access to properties echo $descendant->publicVar; // descendant's public var echo $descendant->staticVar; // "" echo $descendant::$staticVar; // descendant's static var //echo $descendant::$publicVar; // fatal error: Access to undeclared static property: Descendant::$publicVar //echo Ancestor::$publicVar; // fatal error: Access to undeclared static property echo Ancestor::$staticVar; //ancestor's static var //echo Descendant::$publicVar; // fatal error: Access to undeclared static property echo Descendant::$staticVar; // descendant's static var // access to methods $descendant->publicMethod() //Ancestor::publicMethod();

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)
5.6.130.0100.08318.23
5.6.120.0200.07021.08
5.6.110.0100.08321.00
5.6.100.0070.08320.89
5.6.90.0130.08320.98
5.6.80.0100.08020.45
5.5.290.0100.07017.98
5.5.280.0030.04020.67
5.5.270.0070.06720.77
5.5.260.0100.07720.67
5.5.250.0130.04320.73
5.5.240.0070.07720.38
5.4.450.0430.05019.62
5.4.440.0400.05719.61
5.4.430.0300.05719.55
5.4.420.0400.05319.60
5.4.410.0400.05319.32
5.4.400.0370.05319.26
5.4.390.0330.05019.02
5.4.380.0370.05319.29
5.4.370.0400.04719.26
5.4.360.0400.05019.13
5.4.350.0330.05319.16
5.4.340.0270.06318.84
5.4.320.0370.05719.15
5.4.310.0370.05019.29
5.4.300.0430.04319.06
5.4.290.0330.06018.84
5.4.280.0370.05318.89
5.4.270.0430.06318.84
5.4.260.0370.05319.28
5.4.250.0370.05319.13
5.4.240.0430.04718.97
5.4.230.0330.05719.14
5.4.220.0300.05719.03
5.4.210.0230.06019.14
5.4.200.0400.04719.28
5.4.190.0330.05319.38
5.4.180.0470.04318.85
5.4.170.0330.06719.22
5.4.160.0370.05019.04
5.4.150.0370.05318.85
5.4.140.0370.04716.59
5.4.130.0370.04316.35
5.4.120.0270.05316.77
5.4.110.0370.04716.26
5.4.100.0300.05016.27
5.4.90.0370.04316.50
5.4.80.0270.05316.68
5.4.70.0500.03316.61
5.4.60.0100.05316.53
5.4.50.0100.05016.23
5.4.40.0200.04316.18
5.4.30.0030.04316.44
5.4.20.0230.06016.51
5.4.10.0330.04316.29

preferences:
134.91 ms | 1409 KiB | 7 Q