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 = $this->tpl; foreach ($this->data as $_key => $_value) { $out = str_replace('#{{' . $_key . '}}', $_value, $out); } $out = preg_replace('/#{{.*?}}/' , '' , $out ); return $out; } } $t = new MicroTemplateEngine('<#{{element}} id="element-#{{id}}">#{{inner}}</#{{element}}>'); $t->data = (object)array('element'=> 'span', 'id'=>45, 'inner' => 'Teste templating engine!'); var_dump($t); echo $t;
Output for git.master, git.master_jit, rfc.property-hooks
object(MicroTemplateEngine)#1 (2) { ["data"]=> object(stdClass)#2 (3) { ["element"]=> string(4) "span" ["id"]=> int(45) ["inner"]=> string(24) "Teste templating engine!" } ["tpl":"MicroTemplateEngine":private]=> string(60) "<#{{element}} id="element-#{{id}}">#{{inner}}</#{{element}}>" } <span id="element-45">Teste templating engine!</span>

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.81 ms | 402 KiB | 8 Q