3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function pipe(&$_) { return new class($_) { private $_; public function __construct(&$_) { $this->$_ = &$_; } public function __call(string $name, array $args) : self { $this->_ = $name(...$args); return $this; } }; } pipe($blah)->strtoupper('hello')->strrev($blah); echo $blah;
based on SXr69
Output for 7.1.0 - 7.3.0alpha1
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught Error: Cannot access empty property in /in/vee4L:8 Stack trace: #0 /in/vee4L(4): class@anonymous->__construct(NULL) #1 /in/vee4L(18): pipe(NULL) #2 {main} Next Error: Cannot access empty property in /in/vee4L:8 Stack trace: #0 /in/vee4L(4): class@anonymous->__construct(NULL) #1 /in/vee4L(18): pipe(NULL) #2 {main} thrown in /in/vee4L on line 8
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Cannot access empty property in /in/vee4L:8 Stack trace: #0 /in/vee4L(15): class@anonymous$;81919476->__construct() #1 /in/vee4L(18): pipe() #2 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/vee4L on line 4
Process exited with code 255.