11

I hate that google can not search for symbols. I saw this in some sample code and wondered why there is an @ sign before the readfile function:

@readfile($filename);

What does it mean different to without an @ symbol?

Jonathan.
  • 53,997
  • 54
  • 186
  • 290
  • 1
    Also, as a heads up for next time whenever you come across a symbol, try spelling it out instead, i.e 'at sign' you might be able to find more results. – Anthony Forloney Apr 16 '10 at 16:30
  • 3
    Also, PHP has a pretty good online help. For the most part you can simply do `http://php.net/[something]` and get to the right page. And yes, in this case, the `[something]` can actually be `@`: http://php.net/@ – Joey Apr 16 '10 at 16:33
  • use this while googling "@readfile()" – RSK Apr 16 '10 at 19:12
  • would you consider renaming the issue to something like "what does the @ symbol mean before a PHP function?" – tmsimont Jul 08 '11 at 17:35

6 Answers6

20

An @ before a command in PHP means that no errors are printed. It's called the error control operator.

If you removed the @ and readfile would encounter an error (such as not being able to read the file), then—depending on your PHP settings—the error message will be amidst your site content; something you rarely, if ever, want. (It gets worse even, if this happens before a call to header() or start_session() because once content is sent, the headers can't be written anymore.)

Joey
  • 344,408
  • 85
  • 689
  • 683
10

I refer to @ as being the "stfu operator".

goat
  • 31,486
  • 7
  • 73
  • 96
6

It is PHP's error suppression operator. With it you can suppress error messages.

Tip:

Simply don’t use the error suppression operator with speed-critical code.

Future:

Because @ operator is very slow, it won't work on ini_set eg @ini_set in future version of PHP eg PHP6

Important Reading:

Bad uses of the @ operator

Sarfraz
  • 377,238
  • 77
  • 533
  • 578
5

It's error control operator. Manual will tell you everything...

Crozin
  • 43,890
  • 13
  • 88
  • 135
3

@ means "don't show errors/warnings"

a1ex07
  • 36,826
  • 12
  • 90
  • 103
0

FYI

You can use " " to search queries containing special characters in google.

Example to search - @readfile in PHP? search it

You can search - "@readfile in PHP?" search it

ABHi
  • 404
  • 4
  • 8