Log In · Register

 
PHP operator (?) question, The @ symbol
*mipadi*
post Jul 27 2005, 08:43 AM
Post #1





Guest






Question for people who are more knowledgeable about PHP than I:

I've been looking through some source code in an effort to update/modify a script, and I've run into a @ being prepended to some functions. What exactly is the purpose of this operator (if it is an operator)? Below are some examples of the code in question (note they are just pieces of code and don't actually go together):

if (@phpversion() < '4.0.0')
@reset($test)
if (@ini_get('register_globals')

I'm wondering if it has something to do with the value returned (much like how you use the & operator to pass by reference instead of value) but I'm not sure. Anyone know this one?
 
 
Start new topic
Replies (1 - 4)
hlall
post Jul 27 2005, 11:47 PM
Post #2


Senior Member
****

Group: Member
Posts: 101
Joined: Sep 2004
Member No: 49,477



it turns off error reporting for that function.
 
*mipadi*
post Jul 28 2005, 07:20 AM
Post #3





Guest






Ah, right... I think I had learned that somewhere, but never actually used it. Thanks!
 
hlall
post Jul 28 2005, 06:44 PM
Post #4


Senior Member
****

Group: Member
Posts: 101
Joined: Sep 2004
Member No: 49,477



your welcome.

oh and a common use for this is with mysql.

$connect = @mysql_connect("","","");
$db = @mysql_select_db("");
if(!$connect){
die("Problem connecting to database");
}
if($connect && !$db){
die("Problem selecting database");
}


this way the errors are more friendly. there are also functions to display the mysql error.

i assume this thread can be closed :)
 
*mipadi*
post Jul 28 2005, 10:33 PM
Post #5





Guest






Oh, okay. Well, I wrote my own function for handling MySQL errors, but this is good to know now.
 

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: