Adding these two little lines at the top of your code can often solve a world of questions you have on why your code isn’t working.

error_reporting(E_ALL);
ini_set('display_errors', '1');

Make sure they are placed at the very top right after the opening <?php tag. If anything is output before them it will not work properly.

Another helpful tool is to run a php dash “L” from your command line (for Linux environments). This will check your php file for any obvious errors.

php -l /path/to/file.php

It is strongly recommended to have clean code that doesn’t output any errors, warnings or notices. Even though notices aren’t breaking your code, it’s good practice to zap them out as they can cause issues in certain circumstances. Plus, it’s a PEAR Standard. 🙂

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments