3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Renderer { function render(array $_data) { // normally you'd have some file you'd render from... $_data = $this->escapeData($_data); extract($_data, EXTR_SKIP); return <<<LIST {$foo}\n {$bar}\n {$baz}\n LIST; } private function escapeData(array $data) { $safe = []; foreach ($data as $var => $value) { if (is_array($value)) { $safe[$key] = $this->escapeData($value); } else { $safe[$key] = htmlspecialchars($value); } } return $safe; } } $renderer = new Renderer(); $unsafe = ['foo' => '<script>alert("xss");</script>', 'bar' => '<b>something</b>', 'baz' => '<i>foo</i>']; echo $renderer->render($unsafe);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $key in /in/rRFMo on line 23 Warning: Undefined variable $key in /in/rRFMo on line 23 Warning: Undefined variable $key in /in/rRFMo on line 23 Warning: Undefined variable $foo in /in/rRFMo on line 10 Warning: Undefined variable $bar in /in/rRFMo on line 11 Warning: Undefined variable $baz in /in/rRFMo on line 12

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:
39.31 ms | 402 KiB | 8 Q