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 42429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:20:12+00:00 2026-05-10T15:20:12+00:00

What kind of performance implications are there to consider when using try-catch statements in

  • 0

What kind of performance implications are there to consider when using try-catch statements in php 5?

I’ve read some old and seemingly conflicting information on this subject on the web before. A lot of the framework I currently have to work with was created on php 4 and lacks many of the niceties of php 5. So, I don’t have much experience myself in using try-catchs with 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. 2026-05-10T15:20:12+00:00Added an answer on May 10, 2026 at 3:20 pm

    One thing to consider is that the cost of a try block where no exception is thrown is a different question from the cost of actually throwing and catching an exception.

    If exceptions are only thrown in failure cases, you almost certainly don’t care about performance, since you won’t fail very many times per execution of your program. If you’re failing in a tight loop (a.k.a: banging your head against a brick wall), your application likely has worse problems than being slow. So don’t worry about the cost of throwing an exception unless you’re somehow forced to use them for regular control flow.

    Someone posted an answer talking about profiling code which throws an exception. I’ve never tested it myself, but I confidently predict that this will show a much bigger performance hit than just going in and out of a try block without throwing anything.

    Another thing to consider is that where you nest calls a lot of levels deep, it can even be faster to have a single try…catch right at the top than it is to check return values and propagate errors on every call.

    In the opposite of that situation, where you find that you’re wrapping every call in its own try…catch block, your code will be slower. And uglier.

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

Sidebar

Related Questions

I thought I read somewhere that ordering your using statements and getting rid of
Really hoping that some kind of performance whiz can explain to me why a
Is there any performance or any kind of effect on OS's file system permission
Is there an analytics tool of any kind to analyse the performance of selectors
Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() {
Kind sirs, I'm using Codeigniter to build a blog. I might need a way
What kind of audio files are you using in your iPhone games/apps? I have
what kind of 'unique' system identifiers can be easily obtained using C# (to hash
What kind of performance can I expect from WebGL on existing devices? This is
Does anyone have any experience that indicates what kind of performance hit a developer

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.