Why use @ in a variable?

Asked

Viewed 157 times

0

I was analyzing some codes PHP I didn’t program and I found a @ (arroba) before a variable. What is its usefulness in the code?

if( @$f_outro_valor ){ $where[] = " `f_valor` = '{$f_outro_valor}'"; }

1 answer

3


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

This solution will no longer display notices like the Unexpected Index she basically has the same function as @ at the beginning of expressions suppressing the need to use it, This solution NAY is indicated in 99% of cases so never suppress errors unless it is extremely necessary.

To set up php.ini to not display the notification messages you should leave it as follows:

error_reporting  =  E_ALL & ~E_NOTICE

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

ini_set("display_errors", "0");

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

error_reporting(E_ALL ^ E_NOTICE); // ira reportar todos esceto os `notices`.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.