Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6145

Re: On the usage of "@" (error control operator)

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: On the usage of "@" (error control operator)
Date 2012-05-23 16:14 -0400
Organization A noiseless patient Spider
Message-ID <jpjgg4$b97$2@dont-email.me> (permalink)
References <jpio02$942$1@dont-email.me> <jpiq01$km7$1@dont-email.me> <jpitd2$bc8$1@dont-email.me> <jpj296$bh7$1@dont-email.me> <jpjb7d$8ru$1@dont-email.me>

Show all headers | View raw


On 5/23/2012 2:45 PM, Leonardo Azpurua wrote:
> "Jerry Stuckle"<jstucklex@attglobal.net>  escribió en el mensaje
> news:jpj296$bh7$1@dont-email.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@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

On the usage of "@" (error control operator) "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-23 08:47 -0430
  Re: On the usage of "@" (error control operator) Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-23 09:50 -0400
    Re: On the usage of "@" (error control operator) "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-23 10:19 -0430
      Re: On the usage of "@" (error control operator) Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-23 12:12 -0400
        Re: On the usage of "@" (error control operator) "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-23 14:15 -0430
          Re: On the usage of "@" (error control operator) Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-23 16:14 -0400
  Re: On the usage of "@" (error control operator) Shake <QUITAESTO@QUITAESTO.NOES> - 2012-05-23 16:12 +0200
    Re: On the usage of "@" (error control operator) "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-23 10:22 -0430
      Re: On the usage of "@" (error control operator) Shake <QUITAESTO@QUITAESTO.NOES> - 2012-05-23 17:11 +0200
        Re: On the usage of "@" (error control operator) "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-23 10:44 -0430
    Re: On the usage of "@" (error control operator) Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-23 12:13 -0400
  Re: On the usage of "@" (error control operator) Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2012-05-24 22:26 +0200

csiph-web