3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DataCollector { private $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' ); $Field1->getCollectedData(); $Field2 = new Field; $Field2->getCollectedData( 'html', 'hello' );
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/YrCCB on line 5 Deprecated: Creation of dynamic property Field::$CollectionData is deprecated in /in/YrCCB on line 6 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Field::__construct(), 0 passed in /in/YrCCB on line 28 and at least 1 expected in /in/YrCCB:20 Stack trace: #0 /in/YrCCB(28): Field->__construct() #1 {main} thrown in /in/YrCCB on line 20
Process exited with code 255.

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:
47.61 ms | 401 KiB | 8 Q