Re: On the usage of "@" (error control operator) [message #178210 is a reply to message #178208] |
Wed, 23 May 2012 14:52 |
Leonardo Azpurua
Messages: 46 Registered: December 2010
Karma:
|
Member |
|
|
"Shake" <QUITAESTO(at)QUITAESTO(dot)NOES> escribió en el mensaje
news:jpir8f$til$1(at)dont-email(dot)me...
> El 23/05/2012 15:17, Leonardo Azpurua escribió:
>> Hi,
>>
>> A few weeks ago, I wrote this sentence:
>>
>> @$retVal = $this->lastfetch[$ndx];
>>
>> Yesterday, browsing the manual, I found this paragraph:
>>
>> "PHP supports one error control operator: the at sign (@). _When
>> prepended
>> to an expression_ in PHP, any error messages that might be generated by
>> that
>> expression will be ignored."
>>
>> and, a few lines further:
>>
>> "A simple rule of thumb is: if you can take the value of something, you
>> can
>> prepend the @ operator to it."
>>
>> 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?
>>
>
> Both forms works, but not both forms are the same:
>
>
> $retVal = @$this->lastfetch[$ndx];
> (....errors ignored....)
>
> @$retVal = $this->lastfetch[$ndx];
> (.........Errors ignored.........)
>
>
> Perhaps in some cases "$retVal" could throw a type casting error or
> something of this kind.
Thanks.
Is there any chance that a type casting error occurs in such a statement?
--
|
|
|