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
https://forums.phpfreaks.com/topic/257018-the-symbol-on-variables/
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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.