3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Renderer { function render(array $_data) { // normally you'd have some file you'd render from... 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 = ['<script>alert("xss");</script>', '<b>something</b>', '<i>foo</i>']; echo $renderer->render($unsafe);
Output for 5.4.0 - 7.1.0
Notice: Undefined variable: foo in /in/bXjWv on line 9 Notice: Undefined variable: bar in /in/bXjWv on line 10 Notice: Undefined variable: baz in /in/bXjWv on line 11
Output for 5.1.0 - 5.1.1, 5.1.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/bXjWv on line 17
Process exited with code 255.
Output for 5.1.2
Parse error: syntax error, unexpected '[' in /in/bXjWv on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/bXjWv on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/bXjWv on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/bXjWv on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/bXjWv on line 5
Process exited with code 255.