tags:

views:

99

answers:

5

What is the difference between these two function calls in PHP?

init_get($somevariable);

@init_get($somevariable);

Thanks.

+6  A: 

It silences errors and warnings. See Error Control Operators.

Jonathan Sampson
+1  A: 

http://www.faqts.com/knowledge_base/view.phtml/aid/18068/fid/38

All PHP expressions can be called with the "@" prefix, which turns off error reporting for that particular expression.

George
+11  A: 

the @ will silent any php error your function could raise

solidgumby
A: 

As already answered the @ will stop the error (if any) from showing up.
In terms of performance this is not recommend.

What php is doing is:

  • reading the error display state
  • setting the error display to show no errors
  • running your function
  • setting the error display to it's previous state

If you don't want any errors showing up use:

error_reporting(0);

Or just to write bug free code :P

AntonioCS
Or `error_reporting(NONE);`
John
Prefer to put zero, but if that works, great didn't know about it :)
AntonioCS
A: 

As everyone said, it stops the output of errors for that particular function. However, this decreases performance greatly since it has to change the error display setting twice. I would recommend NOT ignoring warnings or errors and fixing the code instead.

Daniel S
Thanks to all for your answers. That code is not mine, I was only looking at the phpBB code for curiosity, so I have no problems of performance. :) Thanks again.
nixie