Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the @ character do in PHP? [duplicate]

Tags:

php

Possible Duplicates:
Reference - What does this symbol mean in PHP?
What does @ mean in PHP?

I have a line in my code which looks like this:

@mysql_select_db($dbname) or die( "Error: Unable to select database");

It works, but I want to know what the @ does and why it is there.

like image 960
Margarez Avatar asked Dec 06 '22 00:12

Margarez


1 Answers

The @ symbol suppresses any errors and notices for the expression it precedes.

See this reference: PHP Error Control Operators

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.

like image 94
Jonathon Bolster Avatar answered Dec 20 '22 07:12

Jonathon Bolster