Re: On the usage of "@" (error control operator) [message #178221 is a reply to message #178215] |
Wed, 23 May 2012 18:45 |
Leonardo Azpurua
Messages: 46 Registered: December 2010
Karma:
|
Member |
|
|
"Jerry Stuckle" <jstucklex(at)attglobal(dot)net> escribió en el mensaje
news:jpj296$bh7$1(at)dont-email(dot)me...
> On 5/23/2012 10:49 AM, Leonardo Azpurua wrote:
>> So, I must search an identifier in several associative arrays. And trying
>> to
>> access an array element with an invalid index triggers an error.
Hi,
I might have a valid index or not. And if it is valid, it could be valid on
one among several arrays.
Anyway, I just learnt that isset($arr[$ndx]) does not fire an error if $ndx
is not valid on $arr.
So, instead of
@$x = $arr[$ndx];
if (isset($x)) {
...
}
I should have written
if (isset($arr[$ndx])) {
$x = $arr[$ndx];
...
}
avoiding the rather ugly original construct.
Thanks!
--
|
|
|