3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NewClass { public $id; //here's your registry protected static $registry = array(); public function __construct($id) { $this->id = $id; $this->checkVars(); //if not failed, add to registry: self::$registry[] = $id; } public function checkVars() { if (empty($this->id)) { trigger_error('ID is a required parameter.'); } //checking if it's already used: elseif (in_array($this->id, self::$registry)) { trigger_error('ID "'.$this->id.'" was used already. Please insert a unique name.'); } } } $object1 = new NewClass('id1'); $object2 = new NewClass('id2'); $object3 = new NewClass('id1');
Output for git.master, git.master_jit, rfc.property-hooks
Notice: ID "id1" was used already. Please insert a unique name. in /in/lUX2P on line 26

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.2 ms | 401 KiB | 8 Q