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
Instead of guessing at what went wrong, let's allow PHP to respond with the errors it encountered. We'll review the error levels and talk about how to display those errors to the screen.
Error Levels
Notice: PHPs way off telling you: "You probably shouldn't be doing what you're doing, but I'll let you do it anyway". Notice errors will not stop the execution of the script. An example of a notice would be when you try to access an undefined variable. Defining a variable before accessing that variable is not required, but it is good practice and could indicate there is something missing.
Warning: PHPs way off telling you: "Youβre doing something wrong and it is very likely to cause errors in the future, so please fix it". As with Notice errors, Warning errors will not stop execution of the script. For example: trying to include a file that is missing, or calling a function with the incorrect number of parameters would each produce a warning.
Fatal Error: PHPs way off telling you: "Youβve done something wrong and I don't know how I'm supposed to process this script". Fatal errors are caused when PHP encounters a logical error. There is no issue with the syntax and the script is readable, however, what youβre asking the script to do can't be done. For example: Dividing by zero, trying to access a function that doesnβt exist, or running out of memory. Fatal errors DO stop the execution of the script.
Showing the Errors
There are different locations where we can control what error types are to be reported:
- In the php.ini file
- In the .htaccess file on your web server
- From your own PHP code.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated 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