Jump to content

The @ symbol on variables


rorybing

Recommended Posts

Hi,

 

I'm looking through some code I have for setting up a rating system. It was a free open source code, which I need to change to work for my own site. I have it working, but I am now just looking through the code to try and understand it, and for the most part, I do.

 

There is one part I am not familiar with, if somebody could help me please?

 

Values involved;

$current_rating = total rate value of votes

$count = total number of votes cast

 

Problem I have is the @ symbol here

$rating=@number_format($current_rating/$count, 1);

 

Does it format it to decimal places or something like that? It's probably something simple I know, but I am a relative newb.

 

Thanks.

 

 

Link to comment
Share on other sites

The @ symbol is used to suppress errors and should really be avoided and only used when it really is necessary.

 

In this instance, I think they are trying to hide any "divide by zero" error. This could (and should) be better handled by ensuring that $count is bigger than 0 before using it.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.