How to hide notice errors in PHP

Posted on August 30, 2008, under PHP 


The PHP notice errors are sometimes frustrating and you are tired of seeing them when you are working on your scripts. They are showed at the beggining of your pages and may reveal confidential information to the visitor like the path to the file or the php file name (in case you are using friendly URLs).

There are cases when they are useful (for instance when you defined a constant twice or when you use a variable that hasn’t been defined), but there are situations when everything works fine on your site and you don’t really need them. Here’s the code that you should use:

error_reporting (E_ALL ^ E_NOTICE); /* 1st line (recommended) */

NOTE: Many programmers make mistakes while working on large applications so if there are cases when something is not working right on your site and you hided the notice errors, consider turning them on. They might tell you some bugs in your scripts.

Happy coding!

Comment via Facebook


8 Replies to "How to hide notice errors in PHP"

  1. thx u very much buddy!…

  2. that solves the problem. thank you bro. i owe you hehe.

  3. thankz! that really helps me! :)

  4. thanks ! it helps.

  5. Thanks mate!!!

  6. Thanks man!

  7. Thanks for your help! You rock!

  8. thanks greate job

Leave a Reply

* = required fields

  (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Note: If you want to post CODE Snippets, please make them postable first!
(e.g. <br /> should be converted to &lt;br /&gt;)


  • The comment must be relevant with the topic of the post.
  • Only comments with real email addresses will get approved. So, emails like '' will not be accepted.
  • Do not post the same message in multiple articles through the site.
  • Do not post advertisements, junk mail or pyramid schemes.
  • In case you post a link to another site, please explain briefly where the link goes as a courtesy to other users.
  • Do not post comments such as: "Thank you", "Awesome", "Nice tutorial", "Merci", etc.