Why use @ in a variable? [duplicate]

0

I was looking at some PHP codes that I did not program and found a @ (arroba) before a variable. How useful is it in the code?

if( @$f_outro_valor ){ $where[] = " 'f_valor' = '{$f_outro_valor}'"; }
    
asked by anonymous 13.07.2015 / 16:26

1 answer

3

Using @ in front of expressions is used to suppress error display on the screen (but does not eliminate the occurrence of errors).

  

This solution will not show more notices as Unexpected Index it basically has the same function as @ at the beginning of the expressions suppressing the need to use it, this solution NOT is indicated in 99% of cases so never delete errors unless it is extremely necessary.

To configure php.ini to not display notification messages, you should leave it as follows:

error_reporting  =  E_ALL & ~E_NOTICE

Another way is to paste this line into the start file of the .php file:

ini_set("display_errors", "0");

Another way is to paste this line into the start file of the .php file:

error_reporting(E_ALL ^ E_NOTICE); // ira reportar todos esceto os 'notices'.
    
13.07.2015 / 16:29