3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a = 1; } function deprivatise($obj, $callback) { $thief = function($obj) use ($callback) { call_user_func($callback, $obj); }; $objTheif = Closure::bind($thief, null, $obj); return $objTheif($obj); } $bar = new Foo; echo deprivatise($bar, function($ths) { return $ths->a; }) . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Cannot access private property Foo::$a in /in/Pcseo:20 Stack trace: #0 /in/Pcseo(11): {closure}(Object(Foo)) #1 /in/Pcseo(14): Foo::{closure}(Object(Foo)) #2 /in/Pcseo(19): deprivatise(Object(Foo), Object(Closure)) #3 {main} thrown in /in/Pcseo on line 20
Process exited with code 255.

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:
36.37 ms | 401 KiB | 8 Q