Is there any problem using the '@' while writing the code? and what is the mechanism behind it?
It suppresses error reporting so I guess it makes debugging a little harder ;-)
The @ operator in PHP is an error control operator. It suppresses errors for any expression that it precedes.
The only obvious problem is that it makes your code more difficult to debug.
EDIT: Since a commenter asked... It's actually rather useful in situations where you want to make use of a variable that might not exist - such as a $_GET or $_POST variable.
if (isset($_GET['hello'] && $_GET['hello'] == "yes") {} // without @
if (@$_GET['hello'] == "yes") {} // with @
Some php functions also throw errors as well as returning false so in those situations you might want to suppress the error and check the return value instead of a try and catch.
WARNING: Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.
It can be useful if you are using an external library that triggers an error which you can safely ignore. Simple example would be a library that triggers an error when it fails to connect to an external service, if you can deduce it failed based on a return value from a function you can use the @ operator to suppress the relatively unneeded error.
I'd never use it while coding though as it makes debugging the code rather difficult if you have no errors to work with, only use it on code you know "works" but can throw the odd error you're not interested in.
Not only will it suppress errors you might need to know about, but it slows down your code regardless of whether any errors are encountered. @ works by temporarily setting the php ini setting for error reporting to 0, then back to the previous setting.
Using @ in ANY context is a bad idea. It is almost ok to evaluate some variable
$x = @ $somearray[$somethingelse]; # suppress E_NOTICE if array key is absent
But in any other context it's absolutely terrible. The worst is calling a function with "@" in effect - the entire function and its own subroutines would then be executed with error reporting disabled. If any of those was to throw a fatal exception, you wouldn't have a clue where or what.
PHP error handling it terrible. But using @ is worse.
Sadly there is no operator to just suppress some (e.g. just E_NOTICE and E_WARN) and not others.