User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,814 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,525 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 345 | Replies: 6 | Solved
Reply
Join Date: Dec 2007
Posts: 9
Reputation: kusal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kusal kusal is offline Offline
Newbie Poster

why use @

  #1  
Mar 29th, 2008
sometime I see pepole use @ with variables
ex:
@$cat=$_GET['cat'];

is this something like pass by reference?

can you direct me to a good tutorial in this matter

Thank you
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 64
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster in Training

Re: why use @

  #2  
Mar 29th, 2008
@ help in error handling
Reply With Quote  
Join Date: Oct 2007
Location: South Africa
Posts: 59
Reputation: RoryGren is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
RoryGren's Avatar
RoryGren RoryGren is offline Offline
Junior Poster in Training

Re: why use @

  #3  
Mar 29th, 2008
How does it help?

Thanks.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: why use @

  #4  
Mar 29th, 2008
@ doesn't help it error handling, but it supresses the errors.

  1. if(@mysql_num_rows($result) > 0){ //do something

This above code, supresses the warning if there is something wrong with the query. Its not a good practice to have @, because it makes your life very difficult to know where the exact error is.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Oct 2007
Location: South Africa
Posts: 59
Reputation: RoryGren is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
RoryGren's Avatar
RoryGren RoryGren is offline Offline
Junior Poster in Training

Re: why use @

  #5  
Mar 29th, 2008
Thanks, Naveen!
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: why use @

  #6  
Mar 29th, 2008
Originally Posted by nav33n View Post
. Its not a good practice to have @, because it makes your life very difficult to know where the exact error is.



I agree. I have absolutely never used it.... another lazy practice even worse than short tags.

Good code has error handling, not error suppression.


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Dec 2007
Posts: 9
Reputation: kusal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kusal kusal is offline Offline
Newbie Poster

Re: why use @

  #7  
Mar 30th, 2008
Thank you
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC