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