3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { var $my_public = array(); //forward php4 to constructor function foo($one, $two) { $this->my_public[] = 'php4 constructor'; return $this->__construct($one, $two); } //constructor php5 function __construct($one, $two) { $this->my_public[] = 'php5 constructor'; $this->my_public[] = $one; $this->my_public[] = $two; register_shutdown_function(array(&$this, "__destruct")); } function dump() { print_r($this->my_public); } function __destruct () {} } $test = new foo(); $test->dump();

preferences:
41.05 ms | 402 KiB | 5 Q