Jump to content
skaterdav85

Error Suppression With @

Recommended Posts

Can you use the @ symbol in front of any function that may report errors in order to suppress them? When is it good to suppress errors and when to not?

Share this post


Link to post
Share on other sites

Yes you can. It is a good idea when using a MySQL command so people don't see the location of your database.

Share this post


Link to post
Share on other sites

In my humble opinion, the @ error-suppression method is a hack. You would be better served to find an error-handling method that suppresses the errors displayed to the site, but notifies you (the site Admin) by email. That way the client never sees the info as per the previous reply, yet you are notified of the error. As Site Admin, you need to know if/when errors happen in order to fix them. There is a good error-handler function in a book by Larry Ullman titled Php 5 Advanced, second edition. Chapter 2. ISBN : 0-321-37601-3.

Share this post


Link to post
Share on other sites

For production sites it's a good idea to use error logging instead of displaying errors to the screen, that way if people are reporting errors you can just check the error log to see what's happening. I never suppress errors, if an error happens I want to know about it.error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0);That will log all errors and put them in a file called error.log in the same directory as the script.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...