Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
![](https://videos.teamtreehouse.com/stills/TH-WS-BasicErrorsInPHP-V3-stills-0.jpg?token=6995506f_0489b0136ab6fc6d13117c45f5567248666f0123)
- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
When possible, it's usually best to modify the php.ini file on your webserver. This will allow you to turn on all errors and display in development, while locking down the display of errors on production. Using the php.ini file will also allow you to see parse errors that will stop a php script from processing.
The php.ini
file, as mentioned in Before You Start, is only applicable for locally hosted servers or a hosting server you have access to. If you'd like to follow along, make sure that you are developing using a local PHP Dev Environment.
Modify you php.ini file
- While your server is running, go to the phpinfo file in a browser I'm using http://localhost/phpinfo.php
-
Search for “php.ini”. You should see something like “Configuration File (php.ini) Path”. Examples:
MAC /Applications/MAMP/bin/php/php7.0.0/conf
Windows C:\MAMP\conf\php7.0
-
You can open the php.ini file in a text editor or in a terminal. Copy the path and open a terminal window.
MAC: Type sudo vi and then paste the path with php.ini at the endsudo vi /Applications/MAMP/bin/php/php7.0.0/conf/php.ini W
Windows: Open notepad first then choose File > Open or copy the path and open a terminal window, examplenotepad C:\MAMP\conf\php7.0\php.ini
-
Search for error_reporting:
MAC: Type a forward slash to search /error_reporting
Windows: Edit > Find, error_reporting
- error_reporting: Set the error reporting level. The default value is: “E_ALL & ~E_NOTICE,” meaning this this would should all error levels except E_NOTICE. For a development server you probably want to turn everything on by just using E_ALL.
- display_errors: Set it to “ON” (default is “OFF”)if errors are to be printed to the screen.
- log_errors: This indicates whether or not error logging should be done; default value is “on.”
- error_log string: Sets the name of the file where script errors should be logged
-
There are a couple additional settings that will give you more information or control.
- display_startup_errors: For debugging, you can also turn on errors that occur during PHP's startup sequence
- html_errors: You can also control HOW your errors as displayed. The new format for HTML errors produces clickable messages that direct the user to a page describing the error, or function causing the error. This is on by default but you can turn it off
After saving the file, you must restart the servers for the changes to take affect.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Johny Robit
2,440 Points1 Answer
-
marcell gibbs
3,744 Points1 Answer
-
marcell gibbs
3,744 Points1 Answer
-
John Norris
21,145 Points0 Answers
-
Ashley Keeling
11,476 Points1 Answer
-
demian arizaleta
3,382 Points3 Answers
-
Sean Flanagan
33,236 Points7 Answers
-
Sean Flanagan
33,236 Points4 Answers
-
web pad
4,483 Points1 Answer
-
Sam Gord
14,084 Points0 Answers
-
Ellon Shotgun
3,731 Points1 Answer
-
Christopher Parke
21,978 Points1 Answer
-
Obayanju Damilare
3,383 Points0 Answers
-
Josh Foster
8,896 PointsThere isn't a phpinfo.php file in my downloads, or on my workspace as shown in the video. Do I need a server to do this?
Posted by Josh FosterJosh Foster
8,896 Points1 Answer
-
Mihailo Draganic
1,714 Points2 Answers
-
John Lukacs
26,806 Points6 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up