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

General Discussion

Hi all,

Why do we need the underscore for variable like this $email_body,what it is doing there?

thank you,

4 Answers

Short answer....you don't :) Provided you're not using a space a variable name can be anything.

thank you but did not get it little, really short answer :)

Derrick Mull
Derrick Mull
18,518 Points

It's just a naming convention for variables. Helps the code be more readable and have a cleaner appearance.

The $email_body variable could easily be used the same as:

$emailBody
$EmailBody
$emailbody

but never:

$email body

Without the underscore the variable would be broken.

Thanks a lot Derrick really god explaining now I got it