3v4l.org

run code in 300+ PHP versions simultaneously
<?php class asset { protected $id; function __construct($id) { $this->id = $id; } function getId() { return $this->id; } } $getIdsCode = 'array_walk($input, $item->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"; ?>
Output for git.master, git.master_jit, rfc.property-hooks
code length 31 Warning: Undefined variable $item in /in/Hp8AW(27) : eval()'d code on line 1 Warning: Attempt to read property "getId" on null in /in/Hp8AW(27) : eval()'d code on line 1 Fatal error: Uncaught TypeError: array_walk(): Argument #2 ($callback) must be a valid callback, no array or string given in /in/Hp8AW(27) : eval()'d code:1 Stack trace: #0 /in/Hp8AW(27) : eval()'d code(1): array_walk(Array, NULL) #1 /in/Hp8AW(27): eval() #2 {main} thrown in /in/Hp8AW(27) : eval()'d code on line 1
Process exited with code 255.

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:
43.68 ms | 401 KiB | 8 Q