FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » On the usage of "@" (error control operator)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: On the usage of "@" (error control operator) [message #178221 is a reply to message #178215] Wed, 23 May 2012 18:45 Go to previous messageGo to previous message
Leonardo Azpurua is currently offline  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!
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: in_array performance in unsorted vs sorted array
Next Topic: multiple image upload and thumbnail display
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 14:06:49 GMT 2024

Total time taken to generate the page: 0.04721 seconds