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

Error Reporting PHP

Reaching out: I found the php.ini file via C;/ but can't seem to get / error_reporting = to run. I downloaded Bash but it won't allow me to paste from MAMP. What and how is the best way to display errors in my code? Please and thank you.+-9-

2 Answers

Tim Stride
Tim Stride
13,273 Points

This might not be relevant to Bash/MAMP, but adding this php function to the top of a PHP web page file should display any php error(s) when the web page is loaded in the browser:

ini_set('display_errors', '1’);

1 means the function is on, 0 means off.

Thanks Tim. So, pardon my ignorance, but when you say PHP file, would this be the editor where the code is written?

Tim Stride
Tim Stride
13,273 Points

Hi, I'm not sure exactly what your set-up is but you would add that code to the top of any PHP files (directly after opening your '<?php' tag ) that you want to report errors on when the page is displayed in the browser. So, yes in the editor where you are writing the file's code. Then when the web page is loaded in the browser, it will tell you if there were problems with the PHP functionality on that page and on what line of code, to help you identify the problem.