3v4l.org

run code in 300+ PHP versions simultaneously
<?php // No properties key. $schema = ['foo' => 'bar']; if (($schema['properties'] ?? NULL) === []) { $schema['properties'] = 'created'; } print_r($schema); if (($schema['properties'] ?? []) === []) { $schema['properties'] = 'created'; } print_r($schema); // Empty properties key. $schema = ['properties' => []]; if (($schema['properties'] ?? []) === []) { $schema['properties'] = 'created'; } print_r($schema);
Output for 8.1.19 - 8.1.31, 8.2.11 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Array ( [foo] => bar ) Array ( [foo] => bar [properties] => created ) Array ( [properties] => created )

preferences:
57.68 ms | 406 KiB | 5 Q