3v4l.org

run code in 300+ PHP versions simultaneously
<?php function creator($var) { return new class($var) extends StdClass { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; } print "From method:\n"; $a = creator('A'); $b = creator('B'); var_dump($a, $b, $a === $b); print "----------\n"; print "In clear:\n"; $c = new class('C') extends StdClass { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; $d = new class('D') extends StdClass { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; var_dump($c, $d, $c === $d); print "----------\n";
Output for git.master, git.master_jit, rfc.property-hooks
From method: object(StdClass@anonymous)#1 (1) { ["var":protected]=> string(1) "B" } object(StdClass@anonymous)#2 (1) { ["var":protected]=> string(1) "B" } bool(false) ---------- In clear: object(StdClass@anonymous)#3 (1) { ["var":protected]=> string(1) "C" } object(StdClass@anonymous)#4 (1) { ["var":protected]=> string(1) "D" } bool(false) ----------

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.17 ms | 402 KiB | 8 Q