3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = ''; $code = ''; for ($i = 0; isset($input[$i]); $i++) { $code .= $code ? '.' : ''; $code .= sprintf('(function($str, $pos) { $length = (function($str) { for ($l = 0; isset($str[$l]); $l++) {} return $l - 1; })($str); return $str[$length - $pos]; })(%s, %u)', var_export($input, true), $i); } $code = sprintf('return %s;', $code); var_dump($code); var_dump(eval($code));
based on 9At7d
Output for 4.3.3 - 4.4.9, 5.0.2 - 7.2.0
string(8) "return ;" NULL
Output for 5.0.0 - 5.0.1
string(162) "return (function($str, $pos) { $length = (function($str) { for ($l = 0; isset($str[$l]); $l++) {} return $l - 1; })($str); return $str[$length - $pos]; })('', 0);" Parse error: parse error, unexpected T_FUNCTION in /in/X2KvA(14) : eval()'d code on line 1 bool(false)
Process exited with code 255.
Output for 4.3.0 - 4.3.2
Notice: Uninitialized string offset: 0 in /in/X2KvA on line 6 string(8) "return ;" NULL