1

I want to know where and how to use the at sign, like the example below.

if (!@$zip) exit(); 
  • What is it, is there a reference to it?
  • How can i use it?
9
  • 1
    It's an error control operator that suppresses error messages. You should avoid using it though since it will make debugging a real pain. Commented Jul 22, 2019 at 18:42
  • 1
    @SeeQue - It will suppress all errors/warnings/notices, except from catchable errors (which you handle with try/catch instead). So if an expression causes a critical error that can't be caught, then it will silently just stop executing the script. Commented Jul 22, 2019 at 18:54
  • 1
    Ok, thanks for all the comments Commented Jul 22, 2019 at 18:55
  • 1
    It means "I saw this somewhere and no one warned me not to use it". Commented Jul 22, 2019 at 18:57
  • 1
    @SeeQue - Yes, that's why it's a very bad way of handling errors. However, since PHP 7, many of the critical errors are now thrown as catchable errors instead, which you can't silence using @. Commented Jul 22, 2019 at 18:57

1 Answer 1

2

In PHP, the @ is a control operator. When prepended to an expression, any error messages generated by it (except catchable errors) will be ignored.

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

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.