3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(E_ALL); $a = ['key' => false,]; // original with key access arror and correct array but false value var_dump(!$a['key']); var_dump(!$a['key2']); echo PHP_EOL; // changed behavior for false value, array access warning fixed - change in behaviour !!! var_dump(!isset($a['key2'])); var_dump(!isset($a['key2'])); echo PHP_EOL; // this should be used instead, solving array key access error and not changing behaviour var_dump(!($a['key'] ?? false)); var_dump(!($a['key2'] ?? false));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
bool(true) Warning: Undefined array key "key2" in /in/eqqJV on line 9 bool(true) bool(true) bool(true) bool(true) bool(true)
Output for 7.4.0 - 7.4.33
bool(true) Notice: Undefined index: key2 in /in/eqqJV on line 9 bool(true) bool(true) bool(true) bool(true) bool(true)

preferences:
44.77 ms | 1167 KiB | 6 Q