8

Quick question, what is the difference between the following two declarations:

define('I_LIKE_AT_SIGNS', false);

and

@define('I_LIKE_AT_SIGNS', true);

I.e. what does the @-sign do?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Egil Hansen
  • 15,028
  • 8
  • 37
  • 54
  • 1
    possible duplicate of [What is the use of @ symbol in php?](http://stackoverflow.com/questions/1032161/what-is-the-use-of-symbol-in-php) – Mark Elliot Jul 10 '11 at 18:27
  • 3
    6 upvotes for a RTFM type of question? A quick google search for "php at sign" would have answered your question. – NikiC Jul 10 '11 at 18:48
  • @NikiC: I agree, had a brain freeze and defaulted to StackOverflow. – Egil Hansen Jul 10 '11 at 20:34

2 Answers2

13

The @ symbol is PHP's only error control operator, and when prepended to any expression, all errors associated with that expression are suppressed.

In this case, any errors associated with your define expression will be suppressed.

Use of the @ error suppression technique generally isn't encouraged or recommended. Instead, it's much better to use other error capture techniques so you can detect and handle the error.

Mark Elliot
  • 75,278
  • 22
  • 140
  • 160
8

It prevents error messages I believe.

"In PHP, it is used just before an expression to make the interpreter suppress errors that would be generated from that expression" -- From wikipedia

Use with Caution!!

tcnarss
  • 585
  • 5
  • 23