Is it OK to use @ when extracting a possibly missing value from a PHP array? Example:
$value = @$array['possibly_missing_key'];
The intended behavior:
if (isset($array['possibly_missing_key'])) {
$value = $array['possibly_missing_key'];
} else {
$value = null;
}
I want to know, before spreading the usage pattern.
isset
does not detect a probably missing key. Usearray_key_exists
for that. Try$arr = array('notMissing' => NULL);
withisset
– ConkerNULL
– Conker