Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP alias @ function

I'm new to PHP and I'm confused seeing some examples calling a function with a @ prefix like @mysql_ping().

What is it for? Googling / searching is not much of a help since @ gets discarded and 'alias' is not good enough keyword.

like image 489
syaz Avatar asked Sep 26 '08 07:09

syaz


1 Answers

@ suppresses errors, warnings and notices.

You can use it for good purpose if you complement it with a custom error handler or with due check of $php_errormsg variable so you can handle errors properly.

In my experience, this proper usage is not seen very much and is instead used a lot in the bad way, just to hide errors without acting on them.

More info at http://www.php.net/manual/en/language.operators.errorcontrol.php

like image 155
Vinko Vrsalovic Avatar answered Sep 22 '22 15:09

Vinko Vrsalovic