A: When you browse peoples code you may have came across a weird bit of PHP syntax which has an @ symbol infront of a function or variable like so:
<?php $conn = @mysql_connect("localhost", "usr", "pass"); @mysql_select_db("foodb", $conn); ?>
Ever wondered why and what it does? Well what the @ symbol does is supress errors, which means to force PHP to not show the error message. Why would you want to supress errors? You might not want any errors to be shown when your site goes live, such as if your database connection fails php will ouput an error message if error_reporting is turned
You shouldn't really use the @ symbol, actually you should never have to use it if you trap errors correctly it should always be the last option if all other methods of trapping errors fail. Such as for when connecting to mysql in the above code you can do this instead:
$conn = mysql_connect("localhost", "usr", "pass") or die("Error connecting to database");What that now does is trigger the or die cluase, which will stop your script from running and display a simple error message that you have defined yourself, if php was unable to connect to mysql, therefore it doesn't show this nastly looking error message:
Access denied for user 'usr'@'localhost' (using password: YES)
You usually see the @ symbol used by what I call lazy PHP programmers.
Hope that helps understand what the @ symbol does.