What function of @ in PHP ???

Wahyu Raja Reply 11:00 AM
That is Error Handling.

The @ is error suppression operator in PHP.
PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.


In your example, it is used before the variable name to avoid the E_NOTICE error there. If in $_POSTarray, hn key is not set, it will throwE_NOTICE message but @ is used there to avoid that E_NOTICE.
Note that you can also put this line on top of your script to avoid E_NOTICE error:
error_reporting(E_ALL ^ E_NOTICE);

PHP6 Note:

Because @ operator is very slow, it won't work on ini_set eg @ini_set.
You should avoid using it where you can.
Source : http://stackoverflow.com/questions/3551527/php-at-symbol-before-variable-name-post

Related Posts

PHP 1539286632666159909
Facebook Comments by Media Blogger

Post a Comment


Ikuti Channel Youtube Aku Yaa.. Jangan Lupa di subscribe. Terima kasih.

Google+ Followers

Popular Posts