[nycphp-talk] Is @$arr['key'] ok?
ben at projectskyline.com
Sat Mar 8 18:50:28 EST 2008
Personally, I don't like suppressing warnings, even in this case.
I would think, somewhere previously in your code, when you could have
set $arr['key'] to a value,
you should (maybe) set it to null (0, empty string, etc) when you create
it, or somewhere else.
I think it is bad practice to not know if an index is set in array.
Anyways, to answer your questions, I'd vote for the first statement you
$arr = array( );
$arr['key'] = ($something == TRUE) ? null : $somethingElse;
$arr['key'] == null;
Michael B Allen wrote:
> Is there any preference for:
> $val = isset($arr['key']) ? $arr['key'] : null;
> $val = @$arr['key'];
More information about the talk