Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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