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 PHP Basics Unit Converter Integers

Best practice - camel case vs. snake case

Hello, I think the best practice in PHP of writing variables is camel case.

f.e. $bigNumber = 2500; instead of $big_number = 2500;

Futhermore, when you write one line comment you should have one space after slashes

f.e. // This is comment instead of //This is comment

What do you think about it?

1 Answer

Variable style is per language, and for PHP most developers use underscores or "snake" cases. in JavaScript CamelCase is used.

For comments it really depends on what style you feel is best for you and can give the reader insight into what you are doing.

I was not sure because symfony, laravel, yii, nette they all use camel case.