3v4l.org

run code in 300+ PHP versions simultaneously
<?php $wp_version = '6.2.0'; // WP Core code. class Foo { public function __call( $name, $arguments ) { if ( 'new_method_A' === $name || 'new_method_B' === $name || 'new_method_C' === $name ) { return $this->$name( ...$arguments ); } $class = get_class( $this ); $trace = debug_backtrace(); $file = $trace[0]['file']; $line = $trace[0]['line']; throw new BadMethodCallException( "Call to undefined method $class::$name() in $file on line $line" ); } private function new_method_A() { echo __FUNCTION__, ' called!', PHP_EOL; } private function new_method_B() { echo __FUNCTION__, ' called!', PHP_EOL; } public function new_method_C() { echo __FUNCTION__, ' called!', PHP_EOL; } } // Plugin code. $obj = new Foo(); try { $obj->new_method_A(); $obj->new_method_B(); $obj->new_method_C(); } catch(BadMethodCallException $e) { // Do it some other way to support older WP versions. } finally { // Do something with the output of the methods, no matter whether it was created via the code in `try` or the code in `catch`. }
Output for git.master, git.master_jit, rfc.property-hooks
new_method_A called! new_method_B called! new_method_C called!

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