3v4l.org

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