3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class asset { protected $id; function __construct($id) { $this->id = $id; } function getId() { return $this->id; } } $getIdsCode = 'array_walk(count($input), array($asset, "getId"))'; // UPDATE THIS if (strpos($getIdsCode, ';') !== false) die('code should not contain ; !'); $getIdsCode = preg_replace('/\s+/', '', $getIdsCode); echo 'code length '.strlen($getIdsCode)."\n"; $input = array(new asset(10),new asset(20),new asset(30)); echo eval("return $getIdsCode;") . "\n"; $input = array(new asset(40),new asset(50),new asset(60)); echo eval("return $getIdsCode;") . "\n"; ?>
based on qvuo8
Output for 7.0.0 - 7.1.0
code length 47 Notice: Only variables should be passed by reference in /in/WF95L(27) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(27) : eval()'d code on line 1 Warning: array_walk() expects parameter 1 to be array, integer given in /in/WF95L(27) : eval()'d code on line 1 Notice: Only variables should be passed by reference in /in/WF95L(30) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(30) : eval()'d code on line 1 Warning: array_walk() expects parameter 1 to be array, integer given in /in/WF95L(30) : eval()'d code on line 1
Output for 5.3.0 - 5.6.21
code length 47 Strict Standards: Only variables should be passed by reference in /in/WF95L(27) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(27) : eval()'d code on line 1 Warning: array_walk() expects parameter 1 to be array, integer given in /in/WF95L(27) : eval()'d code on line 1 Strict Standards: Only variables should be passed by reference in /in/WF95L(30) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(30) : eval()'d code on line 1 Warning: array_walk() expects parameter 1 to be array, integer given in /in/WF95L(30) : eval()'d code on line 1
Output for 5.1.0 - 5.2.17
code length 47 Strict Standards: Only variables should be passed by reference in /in/WF95L(27) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(27) : eval()'d code on line 1 Warning: array_walk(): The argument should be an array in /in/WF95L(27) : eval()'d code on line 1 Strict Standards: Only variables should be passed by reference in /in/WF95L(30) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(30) : eval()'d code on line 1 Warning: array_walk(): The argument should be an array in /in/WF95L(30) : eval()'d code on line 1
Output for 5.0.5
code length 47 Fatal error: Only variables can be passed by reference in /in/WF95L(27) : eval()'d code on line 1
Process exited with code 255.
Output for 5.0.4
code length 47 Notice: Undefined variable: asset in /in/WF95L(27) : eval()'d code on line 1 Warning: array_walk(): The argument should be an array in /in/WF95L(27) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(30) : eval()'d code on line 1 Warning: array_walk(): The argument should be an array in /in/WF95L(30) : eval()'d code on line 1
Output for 5.0.0 - 5.0.3
code length 47 Notice: Undefined variable: asset in /in/WF95L(27) : eval()'d code on line 1 Warning: array_walk(): The argument should be an array in /in/WF95L(27) : eval()'d code on line 1 Notice: Undefined variable: asset in /in/WF95L(30) : eval()'d code on line 1 Warning: array_walk(): The argument should be an array in /in/WF95L(30) : eval()'d code on line 1
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WF95L on line 4
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_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WF95L on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/WF95L on line 4
Process exited with code 255.