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
hlall
post Jul 28 2005, 06:44 PM
Post #2


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 :)
 

Posts in this topic
mipadi   PHP operator (?) question   Jul 27 2005, 08:43 AM
hlall   it turns off error reporting for that function.   Jul 27 2005, 11:47 PM
mipadi   Ah, right... I think I had learned that somewhere,...   Jul 28 2005, 07:20 AM
hlall   your welcome. oh and a common use for this is wit...   Jul 28 2005, 06:44 PM
mipadi   Oh, okay. Well, I wrote my own function for handli...   Jul 28 2005, 10:33 PM


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