What does @ before a variable mean?

Possible duplicate:
Link - what does this symbol mean in PHP?

I have this assignment:

$buffer=@data _value[$i]; 

what does @ mean?

+4
source share
5 answers

This prevents any warnings or errors when accessing the i th data_value .

See this for more details.

+8
source

@ will suppress errors that the variable is not initialized (will be evaluated as null ).

Also, your code probably lacks $ after @:

 $buffer=@ $data_value[$i]; 
+5
source

It is called the "error management statement." Since this is a task, I believe that you should do the rest yourself.

+1
source

@ in front of the operator means that no warnings / errors should be reported from the result of this operator. Simply put, an error message is suppressed for this statement.

This is especially useful when, for example, @fclose(fopen("file.txt",w")) , which may cause several warnings / errors depending on the situation, but with @ before it all these warnings or errors will be suppressed.

0
source

As above, it suppresses the error if the array key does not exist. A version that will do the same without resorting to dodgy error suppression,

 $buffer = array_key_exists($i, $data_value) ? $data_value[$i] : null; 
0
source

All Articles