34

Possible Duplicate:
What is the use of the @ symbol in PHP?
Reference — What does this symbol mean in PHP?

what does using <?php echo @$fnameerror; ?> mean. why use @ before variable in php

2
  • 1
    See [What is the use of @ symbol in php? ](stackoverflow.com/questions/1032161/…). Commented Nov 11, 2010 at 4:54
  • @Matthew I get the feeling shaz knows what it does in general, just not why it would be used to prefix a variable. Commented Nov 12, 2010 at 2:05

5 Answers 5

28

error control operator .. suppresses error messages ..

Sign up to request clarification or add additional context in comments.

1 Comment

This link is super useful because even after 14 years it's up to date - and it even holds information for the latest PHP 8+
9

@ is pure evil. It's not a good idea to use. You can find an explanation about it here.

It can cause massive debugging headaches because it will even suppress critical errors.

2 Comments

Actually wrong. If you define a custom error handler, you can still receive all messages despite the @ suppression operator. Therefore it's in fact preferable to e.g. isset() decoration.
Maybe so, but I've seen way more people use it without a custom error handler and have way too many headaches dealing with it.
8

It's used to avoid the error notice.

Comments

6

The only reason I can think of to use the error suppression operator before a variable would be to suppress E_NOTICE errors if the variable is undefined.

As others have mentioned, this is a bad idea. It's much better to actually deal with errors than ignore them.

Comments

4

If you want to avoid notices and warnings use @ sign before variable

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.