3v4l.org

run code in 300+ PHP versions simultaneously
<?php class JavaScriptObject { protected $varName; protected $object; protected $jh; public function __constuct() { $this->jh = json_encode; } public function setVarName($varName) { $this->varName = $this->jh->encode($varName); } public function addObject($arg) { $this->object = $this->jh->encode($object); } public function __toString() { return 'var ' . $this->varName . ' = ' . $this->object . ';'; } } $jo = new JavaScriptObject(); $jo->setVarName('v'); $options = new stdObject; $options->size = 10; $options->enabled = false; $jo->addObject($options); echo $jo;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to a member function encode() on null in /in/8IPti:13 Stack trace: #0 /in/8IPti(27): JavaScriptObject->setVarName('v') #1 {main} thrown in /in/8IPti on line 13
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:
48.47 ms | 401 KiB | 8 Q