3v4l.org

run code in 300+ PHP versions simultaneously
<?php class JavaScriptObject { protected $varName; protected $object; public function setVarName($varName) { $this->varName = $varName; } public function addObject($object) { $this->object = json_encode($object); } public function __toString() { return 'var ' . $this->varName . ' = ' . $this->object . ';'; } } $jo = new JavaScriptObject(); $jo->setVarName('v'); $options = new stdClass; $options->size = 10; $options->enabled = false; $jo->addObject($options); echo $jo;
Output for git.master, git.master_jit, rfc.property-hooks
var v = {"size":10,"enabled":false};

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