Can anyone give me its use in PHP?

Member Avatar for nileshgr

Any function if it is prepended with an @ during calling, will suppress the errors the function emits.
Like, if you do @mysql_connect(..) then you will not see the errors.
This works for both, errors from inbuilt functions as well as those raised by trigger_error() (or user_error()).

like .net
Here the extension dot calls all the class ,methods,events,procedures and functions
the same way we can do the database works by using php (@ operator)... imagine if you don't have @ in the beginning,there will be page full of errors..The @ is nothing but calling some functions...

Member Avatar for rajarajan2017

You can get use the @ statment to do some conditions properly

Sample

$mail_sent = @mail( $to, $subject, $message, $headers );
$mail_sent ? "Mail sent" : "Mail failed";
if($mail_sent)
{
header('Location:contactus.php?msg=yes');
}
else
{
header('Location:contactus.php?msg=no');
}
Member Avatar for nileshgr

@mahesh, what do you want to say ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.