Page 1 of 1

what does @$ on a variable mean

Posted: Mon Jul 14, 2014 7:49 am
by jonnyfortis
I have the following code on a page

Code: Select all

<?php
$send = mail($to,$subject,$message,$headers);
?>

<?php
		if(@$send == 1)
		{
			?>
Notification email sent
<?php
		}		
		?>
and i want to know what the function of the @ symbol is before the $send

Re: what does @$ on a variable mean

Posted: Mon Jul 14, 2014 8:22 am
by Celauran
It's an error control operator and its use should mostly be avoided.

Re: what does @$ on a variable mean

Posted: Mon Jul 14, 2014 12:16 pm
by requinix
Besides, in this case there's absolutely no reason to use it: there's no possible error that can result from trying to use $send.

Re: what does @$ on a variable mean

Posted: Mon Jul 14, 2014 1:33 pm
by jonnyfortis
requinix wrote:Besides, in this case there's absolutely no reason to use it: there's no possible error that can result from trying to use $send.
so your saying

Code: Select all

<?php
$send = mail($to,$subject,$message,$headers);
?>

<?php
                if($send == 1)
                {
                        ?>
Notification email sent
<?php
                }               
                ?>
should be used?

Re: what does @$ on a variable mean

Posted: Mon Jul 14, 2014 1:49 pm
by requinix
Yes. The most important point is what Celauran said: avoid @. It suppresses warnings and errors that may be very important to you.