Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 638887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:46:53+00:00 2026-05-13T20:46:53+00:00

I’m new to PHP so I apologize if this seems silly. I’ve searched around

  • 0

I’m new to PHP so I apologize if this seems silly. I’ve searched around and couldn’t find anything that explained specifically what I’m looking for.

Ultimately I have two goals.

  1. In production, when an unexpected error occurs, show the user a default “oops” page.
  2. When an expected error occurs, handle it without PHP dying.

My mental model of PHP error handling is spotty enough that I can’t move forward with any confidence and I haven’t been able to find any good documentation about the process.

To give some contrived examples.

  1. user makes a request, connection to the DB fails, we display an oops message.
  2. user makes a request, script doesn’t parse correctly, we display an oops message.
  3. user makes a request, we query the DB with an update using optimistic locking. It fails, so we inform the user that the object has been updated.

I think most of my confusion is surrounding what errors result in the script dying and what errors do not (using the default handler), and when the script dies, how do we gracefully inform the user?

Also, do any of the standard php functions/objects use exceptions? If I choose to handle exceptions in more of a C style I’m not going to be surprised at any point am I? Is this going to change in PHP6? If so I’ll put forth the effort to paper over the differences between using c style and exceptions, but if not, I’d rather just use the c style consistently throughout PHP5. That is not a problem I am interested in solving unless I absolutely need to.

edit:
I just realized the content doesn’t quite match the title. I would like to know, when an error occurs, what is the logic flow for PHP? This way I can better understand how to go about achieving my goals with respect to error handling in PHP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:46:54+00:00Added an answer on May 13, 2026 at 8:46 pm

    most of PHP’s built in tuff triggers errors that you can’t really deal with in a default setup.

    You can however workaround this by setting up a custom error handler and throwing an exception instead of the error. (PHP will, when possible, run your handler before handling the error internally, so you can actually catch Exceptions in the normal way.)

    I’ve written a bunch of code you could use for this situation in my answer here:
    PHP: exceptions vs errors?

    If php can’t actually parse your file you’re pretty much screwed, php will crash pretty hard under most circumstances where it can’t parse a file. Though you could try writing your own include function that eval‘s a file before including it and just skips if eval failed. You’ll need to be sure you can basically trust the files though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.