Jump to content

@mysql


mikemcc

Recommended Posts

Can anyone please tell me why mysql_ functions sometimes have the 'at sign' @ infront of them, for example @mysql_fetch_assoc ?I have searched for this information in the official and other documentation but can't work out how to search for the @ . Thanks.

Link to comment
Share on other sites

Can anyone please tell me why mysql_ functions sometimes have the 'at sign' @ infront of them, for example @mysql_fetch_assoc ?I have searched for this information in the official and other documentation but can't work out how to search for the @ . Thanks.
The @ is the error suppressor. It the line immediately following the @ throws an error, the error will not be displayed/logged. It is generally bad practice to use these since it makes debugging near impossible.Edit: Ah, scientist is quick on the reply button today. :)
Link to comment
Share on other sites

Sure, but have you tried googling @mysql or "@mysql" (as I did before asking the question) ? Google ignores the @ and offers you 91m hits about mysql. Irritatingly, but for obvious misguided reasons, Google increasingly returns the links it wants to return - rather than paying precise attention to the string one enters within quotes. This is probably a different scenario so maybe someone has a way to prevent it from ignoring the @ ? Thanks.

Link to comment
Share on other sites

Google is great, and I fully support you, but in defense of the OP, it would be nice if w3schools at least mentioned it. mikemcc, you might consider posting the suggestion in the 'Suggestions' forum?
but in all fairness, its kind of what you get for copy/pasting code from the internet without working from the ground up to learn proper conventions, techniques, and debugging skills. And W3Schools is really just a reference, tbh. There's so much more that isn't included that would still be required of any formal/career programmer.
Link to comment
Share on other sites

Yes, thescientist, I don't disagree except:1. It's part of the strength of the internet that one can pick up (often perfectly good) code and thereby take perfectly acceptable shortcuts.2. This @ issue could even be mentioned in a tutorial on good (and bad) debugging.

Link to comment
Share on other sites

There are several places you think they may put it to make it easier for people who don't understand the language, but that's part of the problem. People really need to try to understand the language, if someone doesn't know something basic like "@" is an operator, then they won't know to search for PHP operators. They could search for 1000 things which in their minds make sense, but it doesn't make sense to mention operators in 1000 places when you only need to mention them once. Like thescientist mentioned, the tutorials on w3schools really are pretty incomplete, there's just a lot of information to cover and a lot they left out. Look at the w3schools section on PHP operators, for example:http://www.w3schools.com/php/php_operators.aspThere are 4 types of operators listed, with several operators in each group. Now look at the official PHP manual section on operators:http://www.php.net/manual/en/language.operators.phpThere they list 11 types of operators, not just 4. Obviously the authors of w3schools just had to choose what to put in the tutorials and what to leave out, it shouldn't be considered a complete resource and I don't think the family running it wants to make it a complete resource. If you have questions about PHP, the single best resource will always be the PHP manual. What you can use w3schools for are things like figuring out that @ would be considered an operator, as opposed to a variable, control structure, function, etc.Here's the manual page for the @ operator:http://www.php.net/manual/en/language.oper...rrorcontrol.php

Link to comment
Share on other sites

I'm guessing this is where experience with Java and other languages with 'C' like syntax comes in handy. I just started C but I know from Java programming that the '@' operator is used to suppress compilation messages and to override stuff. I guess as PHP is also 'C' influenced the use is similar (if C has a @ operator).The syntax of C influenced languages and some of their facilities will be inherited from C itself. So understanding of these newer languages should be more than how code in them but also how they work and their background.What justsomeguy makes sense. What if the guys who wrote the tutorials on php use java and C++? Then the meaning of the @ operator to them may be as trivial as a semicolon.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...