newbie question why is '@' used ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Keep it civil.. even jokingly, that's not very nice ole.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Just ran your code bokehman, but the PHP 5 version.
Without error suppression it was 4.2 - 4.7 times faster than with error suppression.
I also tested with $fake = true; to see what happens in that case.

The result:

"Without error suppression is 2.7 times faster than with error suppression".
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

feyd wrote:Keep it civil.. even jokingly, that's not very nice ole.
Fixed
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Oren wrote:I also tested with $fake = true; to see what happens in that case.
I was trying to cut down on the work done to keep the overhead to a minimum and hopefully be timing the error suppression and little else. On my laptop it returns 11.4 while on my production server it returns 8.2.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Well, it doesn't really matter - the conclusion is pretty obvious :P
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I would like to add something here. @ has just saved my ass.
I wrote:Never use @. Ever.
This isn't true. There is no such thing as never in programming, I was being a cock. There is uncredibly rare, but not never. Anyway I experienced an incredibly rare occasion just now as this code snippet will demonstrate:

Code: Select all

$needle = 'something';
$haystack = ''; // nothing
strrpos($needle, $haystack);
mb_strrpos($needle, $haystack); // generates an E_WARNING telling you that your haystack is empty
mb_strrpos should definately not trigger errors but alas is does and the best solution is @.
So there you have it. :D
Post Reply