3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = [ "testA" => true, "testB" => 22, 0 => 0 ]; class Processor { public $systemVarA; public $systemVarB; private function validators() { return [ 'testA' => function($value) { if (!is_bool($value)) throw new \Exception( "Configuration '$name' must be boolean."); $this->systemVarA = $value; }, 'testB' => function($value) { if (!is_int($value)) throw new \Exception( "Configuration '$name' must be integer."); $this->systemVarB = $value; } ]; } public function validate($array) { $validators = $this->validators(); foreach($array as $key => $value) if(is_callable($validators[$key])) $validators[$key]($value); } } $proc = new Processor; $proc->validate($config); var_dump($proc);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 0 in /in/uYHWA on line 31 object(Processor)#1 (2) { ["systemVarA"]=> bool(true) ["systemVarB"]=> int(22) }

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:
33.86 ms | 405 KiB | 5 Q