Hello,

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 provided.

- Ben

ie:

$arr = array( );
...code...
$arr['key'] = ($something == TRUE) ? null : $somethingElse;

or

$arr['key'] == null;

Michael B Allen wrote:
Is there any preference for:

$val = isset($arr['key']) ? $arr['key'] : null;

vs:

$val = @$arr['key'];

?

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to