3v4l.org

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

preferences:
43.14 ms | 402 KiB | 5 Q