Jump to content


Photo

*SOLVED* @ symbol usage


  • Please log in to reply
3 replies to this topic

#1 acedanger

acedanger
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 April 2006 - 01:34 PM

I've been searcing around the web and have noticed some people using the @ symbol in front of mysql_* functions. What does the @ symbol mean and what does it do?

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 29 April 2006 - 01:47 PM

It surpresses error messages, which means it hides the error message which is good on a production server (live site) but not when you are on devlopment server (making your script).

Take this example:
<?php

if($_GET['var']))
{
    echo $_GET['var'] . '<br /><br />';
}

?>
<a href="?var=hello">Set $_GET['var'] </a>
When you run that code depending on you error reporting level and whether display errors is enabled you'll get an notice message like this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined index: var in path/to/file.php on line 3[/quote]
When you add the @ symbol in front of the $_GET['var'] variable it wont show the error message.

Hope that helps. I dont really recommend the use of the @ symbol, unless it is really nessecary, as it is a from of lazy programming.

#3 acedanger

acedanger
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 April 2006 - 01:52 PM

Thanks wildteen88, that's exactly the kind of information I was looking for!

#4 Brandon Jaeger

Brandon Jaeger
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts
  • LocationPA
  • Age:25

Posted 30 April 2006 - 05:21 AM

Thank you :)
PHP is my friend (=




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users