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 #178215 is a reply to message #178209] Wed, 23 May 2012 16:12 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 10:49 AM, Leonardo Azpurua wrote:
> "Jerry Stuckle"<jstucklex(at)attglobal(dot)net> escribió en el mensaje
> news:jpiq01$km7$1(at)dont-email(dot)me...
>>> [snip]
>>> Since an assigment is not an expression, the required syntax should be:
>>>
>>> $retVal = @$this->lastfetch[$ndx];
>>>
>>> But both forms work.
>>>
>>>
>>> Is there any reason to prefer one above the other?
>>>
>>> --
>>>
>>>
>>
>> My preference is to not use it at all and fix the error.
>>
>
> Hi,
>
> In this case there is no error to fix.
>
> I am writing (mostly for study purposes) a Web Interface to the reports of a
> business system of mine. This reports are generated from a user-generated
> script contained in a text file.
>
> Data items may come from several sources, like script defined variables,
> predefined variables, input parameters, database columns or script defined
> formulas.
>
> So, I must search an identifier in several associative arrays. And trying to
> access an array element with an invalid index triggers an error.
>

Then there is an error. So, the solution is to check to see if the
element exists before trying to access it.

> An alternative would be to walk the array comparing each key with the
> desired identifier, but it means more code and, probably, less efficiency
> (even with the overhead of the @ operator).
>

Maybe, maybe not. It depends on a lot of factors.

> Anyway, any advice regarding a cleaner way to do this, will be very
> appreciated.
>
> Thanks!
>
>


--
==================
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: Sat Nov 23 16:51:10 GMT 2024

Total time taken to generate the page: 0.05283 seconds