You are here: Re: [PHP] Error Suppression with '@' « PHP « IT news, forums, messages
Re: [PHP] Error Suppression with '@'

Posted by Torgny Bjers on 08/02/05 21:46

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.
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация