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!
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
A X12,842 Points
Snakecase vs. Camelcase in PHP
In a non-Treehouse resource I found that Snakecase is apparently just as common as Camel because in PHP many of the built in function names are written in Snakecase. Has anyone found one naming convention to be adventitious over the other?
Alexander Davison65,468 Points
Actually, I usually use both in code.
Not only in PHP :)
I use CamelCase for things like class or other big important things, for instance files, and use snake_case for variable names.
Jason AndersTreehouse Moderator 145,826 Points
Neither one has one advantage over another.
However, each language has its own conventions and 'rules' on which one to use and for what. In addition to that, certain companies will have their own style guides but those usually follow the common consensus on which to use in which language.
Some languages use 'upper' CamelCase for classes and such and then use 'lower' camelCase for variables. Some use snake_case (as you put it) for variables. Etc...
So, the best answer is ... it doesn't matter what you prefer. What matters is the language and the rules associated with the language. Even you are freelance, it is best to follow the code's convention (You can Google the style guides and conventions for all languages). This would really only be trumped if you are woking with a group, then you go by the style guide they use.
Hope that helps.
Keep Coding! :)