Re: Error Suppression with '@'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Justin,

I would guess that this is mostly performance and memory related. When,
for instance, trying to iterate an array, or a directory with files,
using @ on all function calls, it will attempt to go through the array,
attempting to allocate memory for each item, but when finding it
empty/broken, it leaves the loop and goes on to the next statement in
the code.

>From what I can tell, PHP handles memory efficiently, although I
wouldn't hazard this when deploying a larger site using this type of
approach. Especially if the code inside a larger if..else block was
performed on an object that was created with @function() call, and then
all the consecutive calls to functions operating on that object also
used @. This would take up both CPU time and memory, possibly creating
leaks, based on how efficiently PHP would handle the operations on a
non-existant object.

A rule of thumb is to instead use empty() and is_array() and such
functions to discern if the object you are going to handle indeed is of
the type you wish it to be, that saves you both time and effort when
trying to debug something in the future. The empty() function goes a
long way here, unless dealing with integers, since empty() will return
true if the value is 0, which might not be desireable.

I hope this helps you in your argument against your fellow developer. :]

Regards,
Torgny

Justin Burger wrote:

>Good Morning,
>I was having a discussion with a fellow PHP Developer this morning and he
>mentioned that he put's an '@' sign in front of all function calls, and
>every time he accesses an array;
>
>I know that this is sloppy, and dangerous, but I don't know exactly what
>this exposes him to, can any one give me any real world examples of why
>this is bad, so I can relate it to his code?
>
>php.net does not have much information about this. It seems like
>suppressing errors, rather then catching them is problematic.
>
>
>Thanks Again.
>
>Justin.
>  
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux