nixie
nixie

Reputation: 1671

@ character before a function call

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

init_get($somevariable);

@init_get($somevariable);

Upvotes: 166

Views: 69844

Answers (5)

AntonioCS
AntonioCS

Reputation: 8496

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

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 write bug free code :P

Upvotes: 41

solidgumby
solidgumby

Reputation: 2634

the "@" will silence any php errors your function could raise.

Upvotes: 252

Daniel Sorichetti
Daniel Sorichetti

Reputation: 1951

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.

Upvotes: 6

George
George

Reputation: 81

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.

Upvotes: 8

Sampson
Sampson

Reputation: 268344

It silences errors and warnings. See Error Control Operators.

Upvotes: 50

Related Questions