3v4l.org

run code in 300+ PHP versions simultaneously
<?php //this seems to work as if there is 2 variables both a public static and a private static class foo{ public static $myvar = 99; //Uncommenting below leads to a Cannot redeclare foo::$myvar //public $myvar = 77; public function __construct(){ $this->myvar = 35; } public function printMyVar(){ echo '->printMyVar(): '.$this->myvar; } public function setMyVar($mv){ $this->myvar = $mv; } } echo "foo before creation: \n"; echo 'static: '.foo::$myvar: '.foo::$myvar."\n"; echo "Creating new instance of foo\n"; $foo = new foo(); echo 'instance: '.$foo->printMyVar(); echo "\n"; echo 'static foo::$myvar: '.foo::$myvar."\n"; $foo->setMyVar(33); echo "After setting $myvar to 33\n"; echo 'instance: '.$foo->printMyVar(); echo "\n"; echo 'static foo::$myvar: '.foo::$myvar."\n"; 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)
5.4.200.0120.03712.40
5.4.190.0140.05212.39
5.4.180.0140.04112.39
5.4.170.0130.03812.40
5.4.160.0110.04012.39
5.4.150.0120.03812.39
5.4.140.0110.03912.08
5.4.130.0100.04112.06
5.4.120.0110.03812.03
5.4.110.0100.03812.03
5.4.100.0120.03812.02
5.4.90.0100.04012.03
5.4.80.0110.03912.03
5.4.70.0120.03712.02
5.4.60.0140.03412.02
5.4.50.0110.03912.02
5.4.40.0090.04112.01
5.4.30.0150.05012.01
5.4.20.0130.03512.00
5.4.10.0090.04012.01
5.4.00.0090.04211.50
5.3.270.0090.04512.73
5.3.260.0180.05012.72
5.3.250.0130.03712.72
5.3.240.0130.04512.72
5.3.230.0120.04312.71
5.3.220.0120.04012.68
5.3.210.0190.05612.68
5.3.200.0130.04112.68
5.3.190.0110.04312.68
5.3.180.0090.04412.67
5.3.170.0120.04112.67
5.3.160.0080.04312.67
5.3.150.0130.03812.67
5.3.140.0110.04112.66
5.3.130.0120.04212.66
5.3.120.0100.04212.66
5.3.110.0110.04212.66
5.3.100.0080.04312.12
5.3.90.0100.04012.10
5.3.80.0110.03912.09
5.3.70.0090.04212.09
5.3.60.0130.03912.07
5.3.50.0090.04312.02
5.3.40.0090.04212.02
5.3.30.0100.04211.98
5.3.20.0100.03911.76
5.3.10.0160.03511.72
5.3.00.0150.03511.71

preferences:
139.97 ms | 1394 KiB | 7 Q