what does @$ on a variable mean

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

what does @$ on a variable mean

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: what does @$ on a variable mean

Post by Celauran »

It's an error control operator and its use should mostly be avoided.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: what does @$ on a variable mean

Post 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.
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: what does @$ on a variable mean

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: what does @$ on a variable mean

Post by requinix »

Yes. The most important point is what Celauran said: avoid @. It suppresses warnings and errors that may be very important to you.
Post Reply