3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php trait DataCollector { static function setData( $data ) { static $CollectionData = array(); $CollectionData[] = $data; } private static function getCollectedData() { static $CollectionData return $CollectionData; } } trait dataHandler { use DataCollector { getCollectedData as public; } } class Form { use DataCollector {} } class Field extends Form { public function __construct( $type, $text = NULL ) { self::setData( $type ); } } $Field1 = new Field( 'text' ); $Field2 = new Field( 'html' ); var_dump( 'Collected Data', dataHandler::getCollectedData() );
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected 'return' (T_RETURN), expecting ',' or ';' in /in/TQdIk on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING in /in/TQdIk on line 2
Process exited with code 255.