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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:36:27+00:00 2026-06-01T12:36:27+00:00

I am very new to programming in general, while reading about PHP I saw

  • 0

I am very new to programming in general, while reading about PHP I saw try {} and catch {} and was wondering if anyone could help me with what they mean?

  • 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-06-01T12:36:28+00:00Added an answer on June 1, 2026 at 12:36 pm

    Entry level primer to exceptions:

    function doSomething($arg1)
    {
        if (empty($arg1)) {
            throw new Exception(sprintf('Invalid $arg1: %s', $arg1));
        }
    
        // Reached this point? Sweet lets do more stuff
        ....
    }
    
    try {
    
        doSomething('foo');
    
        // Above function did not throw an exception, I can continue with flow execution
        echo 'Hello world';
    
    } catch (Exception $e) {
        error_log($e->getMessage());
    }
    
    try {
    
        doSomething();
    
        // Above function DID throw an exception (did not pass an argument)
        // so flow execution will skip this
        echo 'No one will never see me, *sad panda*';
    
    } catch (Exception $e) {
        error_log($e->getMessage());
    }
    
    // If you make a call to doSomething outside of a try catch, php will throw a fatal
    //  error, halting your entire application
    doSomething();
    

    By placing function/method calls within a try/catch block you can control the flow execution of your application.

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

Sidebar

Related Questions

Very new to PHP/programming in general, and I've been trying to run a PHP
I´m very newbie on PHP, and programming in general, and I´m still reading my
I'm very new to jquery and programming in general but I'm still trying to
I'm very new to Python and multithreaded programming in general. Basically, I have a
I'm very new to android, and programming in general. I've got an email receiver
I am very new to Python/Django and programming in general. With the limited tools
I think This question might be very general...I am new to Serial port programming
i am very new to Programming and i am just reading the documents. For
I'm very new to COM and Windows programming/scripting in general. What I was trying
I'm very, very new to Javascript, and to web programming in general. I think

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.