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, array($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 40 Warning: Undefined variable $item in /in/ihRFK(27) : eval()'d code on line 1 Fatal error: Uncaught Error: Call to a member function getId() on null in /in/ihRFK(27) : eval()'d code:1 Stack trace: #0 /in/ihRFK(27): eval() #1 {main} thrown in /in/ihRFK(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:
44.88 ms | 401 KiB | 8 Q