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 #178225 is a reply to message #178221] Wed, 23 May 2012 20:14 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 5/23/2012 2:45 PM, Leonardo Azpurua wrote:
> "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!
> --
>
>

Yup, that's what isset() is for. And this way looks a lot nicer, also :)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Wed Nov 27 09:27:22 GMT 2024

Total time taken to generate the page: 0.04311 seconds