3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php trait DataCollector { static function setData( $data ) { self::collectedData( 'set', $data ); } private function collectedData( $type, $value = NULL ) { static $CollectionData = array(); if( strtolow( $type ) === 'set' ) $CollectionData[] = $value; elseif( strtolow( $type ) === 'get' ) return $CollectionData; } private static function getCollectedData() { self::collectedData( 'get' ) } } 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 '}' in /in/r0MJQ on line 19
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING in /in/r0MJQ on line 2
Process exited with code 255.