3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_val_as_array($val) { $type = gettype($val); echo "val before access = ".var_export($val, true)."\n"; echo "accessing $type as array {$val['test']}\n"; $val['test'] = 'wtf'; echo "set $type offset test to string wtf\n"; echo "accessing $type offset test {$val['test']}\n"; echo "val after access = ".var_export($val, true)."\n"; }; test_val_as_array(null); test_val_as_array('test'); test_val_as_array(123); test_val_as_array(true); test_val_as_array(1.2); test_val_as_array(new stdClass);
Output for git.master, git.master_jit
val before access = NULL Warning: Trying to access array offset on value of type null in /in/PEICX on line 6 accessing NULL as array set NULL offset test to string wtf accessing NULL offset test wtf val after access = array ( 'test' => 'wtf', ) val before access = 'test' Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/PEICX:6 Stack trace: #0 /in/PEICX(14): test_val_as_array('test') #1 {main} thrown in /in/PEICX on line 6
Process exited with code 255.
Output for rfc.property-hooks
val before access = NULL Warning: Trying to access array offset on null in /in/PEICX on line 6 accessing NULL as array set NULL offset test to string wtf accessing NULL offset test wtf val after access = array ( 'test' => 'wtf', ) val before access = 'test' Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/PEICX:6 Stack trace: #0 /in/PEICX(14): test_val_as_array('test') #1 {main} thrown in /in/PEICX on line 6
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:
32.69 ms | 401 KiB | 8 Q