3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { } class XFactory { private $className = 'X'; private function getClassName() { return $this->className; } public function create() { return array( 'member without parens' => new $this->className, 'member with parens' => new $this->className(), // 'method without parens' => new $this->getClassName, # Does not work at all 'method with parens' => new $this->getClassName(), 'method with double parens' => new ($this->getClassName())(), 'method with encapsed parens' => new ($this->getClassName())(), ); } } $factory = new XFactory(); var_dump($factory->create());
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined property: XFactory::$getClassName in /in/ErFI9 on line 22 Fatal error: Uncaught Error: Class name must be a valid object or a string in /in/ErFI9:22 Stack trace: #0 /in/ErFI9(30): XFactory->create() #1 {main} thrown in /in/ErFI9 on line 22
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:
41.6 ms | 401 KiB | 8 Q