3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DataCollector { static $collectionData = array(); final private function setData( $data ) { $this->CollectionData[] = $data; return $this; } public function getCollectedData() { return $this->CollectionData; } } class Form {} class Field extends Form { use DataCollector; public function __construct( $type, $text = NULL ) { $this->setData( $type )->setData( $text ); } } $Field1 = new Field( 'text' ); var_dump( $Field1->getCollectedData() ); $Field2 = new Field( 'html', 'hello' ); var_dump( $Field2->getCollectedData() );
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Private methods cannot be final as they are never overridden by other classes in /in/jCARo on line 5 Deprecated: Creation of dynamic property Field::$CollectionData is deprecated in /in/jCARo on line 6 array(2) { [0]=> string(4) "text" [1]=> NULL } Deprecated: Creation of dynamic property Field::$CollectionData is deprecated in /in/jCARo on line 6 array(2) { [0]=> string(4) "html" [1]=> string(5) "hello" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
36.5 ms | 402 KiB | 8 Q