Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Working With Functions Introducing User-Defined Functions

Ian Hilton
Ian Hilton
6,223 Points

If you have a variable that you want to be a count, why would you name it $count?

If you have a variable that you want to be a count, why would you name it $count? Why would you risk confusing it with the count function? Why not name it $m_count or $fm_count or anything other than count?

2 Answers

Steven Griffiths
Steven Griffiths
3,165 Points

I agree with Ian. It would make it less confusing when teaching beginners of programming not to give variables identical names in these situations.

It's the kind of thing that really can confuse something that could be considered simple.

My take on it is to name your variable in anyway that make sense to you or something that is convenient, as long its not a reserve word or starting with a number.

I have seen count variable as $i, $j $x, $ct. Often use in loops. Comments can be inserted as reminder and avoid any confusion.

For beginners, video and books often uses $count because it easy to understand and is intuitive.