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; } private static function getCollectedData() { return DataCollector::$CollectionData; } } class dataHandler { use DataCollector { getCollectedData as public static; }; } 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 'static' (T_STATIC), expecting ';' in /in/FLAQT on line 15
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING in /in/FLAQT on line 2
Process exited with code 255.