3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MicroTemplateEngine { public $data = array(); private $tpl; function __construct($f) { $this->tpl = $f; } function __set($name, $value) { $this->data[$name] = $value; } function __toString() { $out = file_get_contents($this->tpl); foreach ($this->data as $_key => $_value) { $out = str_replace('#{' . $_key . '}', $_value, $out); } $out = preg_replace('/#{.*?}/' , '' , $out ); return $out; } } $t = new MicroTemplateEngine('<div>{inner}{{inner}}</div>'); $t->inner = array('inner', 'oi'); echo $t;
Output for git.master, git.master_jit, rfc.property-hooks
Warning: file_get_contents(): open_basedir restriction in effect. File(<div>{inner}{{inner}}</div>) is not within the allowed path(s): (/tmp:/in:/etc) in /in/eAScB on line 17 Warning: file_get_contents(<div>{inner}{{inner}}</div>): Failed to open stream: Operation not permitted in /in/eAScB on line 17 Fatal error: Uncaught TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string in /in/eAScB:19 Stack trace: #0 /in/eAScB(19): str_replace('#{inner}', Array, '') #1 /in/eAScB(28): MicroTemplateEngine->__toString() #2 {main} thrown in /in/eAScB on line 19
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:
51.56 ms | 402 KiB | 8 Q