2

I am a newbie in PHP.

I do not know the meaning of @, for example:

$key = @$_REQUEST['key'];

I have searched in google but can not find anything.

Some help me! Please !

5 Answers5

4

The @ symbol tells the function to fail silently instead of dumping some sort of error message. It is listed under error control operators in the PHP manual.

Matt Wonlaw
  • 11,356
  • 5
  • 41
  • 44
2

It suppresses any errors that the line would normally produce. In this case if the key doesn't exist, an error will occur but the error text will be silenced.

Chris Eberle
  • 46,695
  • 12
  • 79
  • 117
1

It suppresses errors and warnings.

spanky
  • 1,349
  • 1
  • 9
  • 22
1

You've found the error control operator!

Matt Stephenson
  • 8,192
  • 1
  • 18
  • 18
1

It suppresses warnings in PHP. In that example it could be used to suppress and undefined index warning, if $_REQUEST['key'] doesn't exist. It's usually better practice to write:

$key = isset($_REQUEST['key']) ? $_REQUEST['key'] : 'default value for key here';
Paul
  • 135,475
  • 25
  • 268
  • 257