SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Aug 22, 2007, 12:15 #1
- Join Date
- Jun 2003
- Location
- India
- Posts
- 162
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Why some use @ before functions ?
Hi,
Why some use @ before php functions ?
For example
@mysql_query($sql);
Here is an code from http://in.php.net/mysql_query
PHP Code:<?
function q($query,$assoc=1) {
$r = @mysql_query($query);
if( mysql_errno() ) {
$error = 'MYSQL ERROR #'.mysql_errno().' : <small>' . mysql_error(). '</small><br><VAR>$query</VAR>';
echo($error); return FALSE;
}
Yujin
-
Aug 22, 2007, 12:19 #2
- Join Date
- Aug 2005
- Posts
- 453
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The @ before a function is an error message supression. You can use this and your code will continue to execute even if there is an error with the function, but if the results of your code are not what you expect and you are looking for causes you might want to leave these out of your code.
Computers and Fire ...
In the hands of the inexperienced or uneducated,
the results can be disastrous.
While the professional can tame, master even conquer.
-
Aug 22, 2007, 12:39 #3
- Join Date
- Jun 2003
- Location
- India
- Posts
- 162
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the reply.
Have another question. I use code like
PHP Code:$result = mysql_query($query);
PHP Code:mysql_query($query);
Removing "$result = " part is correct thing if i have no use of the result ?
-
Aug 22, 2007, 12:42 #4
One of the worst things php has, with all warnings and crap, why wouldn't they just use exceptions, which are already there in php5 since long ago. Gives me real headaches at times.</rant>
Saul
-
Aug 22, 2007, 12:43 #5
Bookmarks