3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ConstructorException extends Exception {} class Foo extends ArrayObject { function __construct( $arr = array(), $flags = 0, $iterator = 'ArrayIterator' ) { $iterator = 'FooIterator'; parent::__construct( $arr, $flags, $iterator ); } } class FooIterator extends ArrayIterator { function __construct( $array = array(), $flags = 0 ) { throw new ConstructorException( 'HELLO WORLD' ); // I AM NEVER CALLED. parent::__construct( $array, $flags ); } } try { $f = new Foo( array( 1, 2, 3 ) ); $it = $f->getIterator(); if ( get_class( $it ) !== 'FooIterator' ) { throw new Exception( 'Expected iterator to be FooIterator.' ); } die( "FAIL\n" ); } catch ( ConstructorException $e ) { die( "PASS\n" ); } catch ( \Exception $e ) { die( sprintf( "ERROR: %s\n", $e->getMessage() ) ); }
Output for git.master, git.master_jit, rfc.property-hooks
FAIL

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