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 trialAngela Riggs
2,539 PointsUnderscore vs Dash
Just a curiosity question, based on my personal preference: why doesn't PHP support dashes for naming conventions? I experimented with using $full-name="Mike The Frog";
instead of $full_name="Mike The Frog";
, but I found that the preview page couldn't display when I used the dash instead of an underscore.
Angela Riggs
2,539 PointsThank you! :)
2 Answers
Kyaw Kyaw Soe
7,528 PointsPHP doesn't allow to use dash (-) and can't start with number digit(1-9) for naming variable
Angela Riggs
2,539 PointsThank you! :)
Aaron Munoz
11,177 PointsI don't know of any language that allows dashes quite honestly.
Angela Riggs
2,539 PointsJavaScript allows for both dashes and underscore, and I got used to using dashes in my coding process :) One less key to press! So now I'm just re-training my fingers' default actions when I type.
Aaron Munoz
11,177 PointsWow, been so long that I forgot that about JS. I use underscores all around for that reason.
Wilhelm LΓΆwe
4,603 PointsWilhelm LΓΆwe
4,603 PointsHi Angela, i gave it a quick try and research and found that a dash in variable names does not work / is not allowed in my working version of PHP. I think it is because the dash in PHP is also the subtraction operator. I use underscores or camelCase names.