3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyCache { private $cache = []; public function has($key) { echo "\nget: " . json_encode($key); return array_key_exists( $key, $this->cache ); } public function set($key, $val) { echo "\nset: " . json_encode($key); $this->cache[$key] = $val; } } $mc = new MyCache(); $mc->has(['x']); $mc->has([]); $mc->has(false); $mc->has(true); $mc->has(''); $mc->has(0); echo "\n"; $mc->set(['x'], 1); $mc->set([], 1); $mc->set(false, 1); $mc->set(true, 1); $mc->set('', 1); $mc->set(0, 1);
Output for git.master, git.master_jit
get: ["x"] Fatal error: Uncaught TypeError: Illegal offset type in /in/3Z0f7:8 Stack trace: #0 /in/3Z0f7(18): MyCache->has(Array) #1 {main} thrown in /in/3Z0f7 on line 8
Process exited with code 255.
Output for rfc.property-hooks
get: ["x"] Fatal error: Uncaught TypeError: Cannot access offset of type array on array in /in/3Z0f7:8 Stack trace: #0 /in/3Z0f7(18): MyCache->has(Array) #1 {main} thrown in /in/3Z0f7 on line 8
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:
30.39 ms | 479 KiB | 5 Q