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 trialDaryl Carr
18,318 PointsHow to add code to github that uses private info like email address and password for phpmailer?
Is there a way to hide this? I want to be able to to push my projects to github to show my php code but I'm not sure how I go about changing these details but keeping them in my local so that I can test etc...
1 Answer
Seth Kroger
56,413 PointsYou can use environment variables in your shell/system and read them in you PHP script through $_ENV like you would $_GET
or $_POST
. That way they aren't stored anywhere but your local system. This is how many web apps deal with secrets like database credentials and such so they are kept out of the code.
Daryl Carr
18,318 PointsDaryl Carr
18,318 PointsGreat, thanks for the help!