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.

Development Tools Using PHP with MySQL Querying the Database with PHP Avoiding Duplication

Does the act of defining constants create a global level security vulnerability?

I understand that in sophisticated programming, encapsulation and obfuscation are important when creating secure applications. So wouldn't this be a bad practice?

1 Answer

Chris Shaw
Chris Shaw
26,649 Points

Hi Sean,

Constants are a lot like variables, the key difference is you can only define constants once meaning they are somewhat more secure than a variable since you can alter it's data at any point in time.

I recommend you have a look at the wp-config.php file in WordPress as it uses constants numerous times throughout it's code base which hasn't contributed to any vulnerabilities once in it's lifetime as a blogging system.

Hope that helps.