3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DataCollector { static function setData( $data ) { static $CollectionData = array(); $CollectionData[] = $data; var_dump( $CollectionData ); } private static function getCollectedData() { static $CollectionData; return $CollectionData; } } trait dataHandler { use DataCollector { getCollectedData as static; } } 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
Fatal error: Cannot use 'static' as method modifier in /in/JRUVD on line 17
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING in /in/JRUVD on line 2
Process exited with code 255.

preferences:
182.96 ms | 1395 KiB | 53 Q