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

PHP Your Own PHP File

Why would we ever want to suppress errors?

I just watched Alena's video on suppressing errors with the htaccess file, but I'm not understanding any situation where this would: A) Work at all when you put your code into production B) Why you'd want to do this in the first place for any reason. Wouldn't you want to fix the errors vs. suppress them? The code won't run without them fixed from what I understand... can anyone clear this up for me? Thanks!

2 Answers

It depends on the error/type whether the program will continue or not. One of the characteristics of PHP whether it's a good thing or a bad thing is that it will try to keep chugging along for as long as it can in spite of errors.

Why it can be a good thing in my opinion? Bugs always seem to slip through the cracks when you make something and I'd rather that I find them personally in an error log than a visitor to a website I make end up at a screen displaying the error.

Scott Lougheed
Scott Lougheed
19,390 Points

Corey's got it. You want to see errors on your "dev" or "development" machine (the one only you see, most likely your personal computer) so you can fix them, as you note.

On a "production" server, which is likely your web host and the version of the site visible to the public, you don't want any minor errors or notices being displayed to users since not all errors completely break your site's functionality, and any errors that did would've likely been identified on the development server anyhow, and ideally wouldn't ever make it onto the production server.

Cliff Jackson
Cliff Jackson
2,887 Points

I get the errors when she gets the blank screen??