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

  • Home
  • SEARCH
  • 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 8948467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:59:53+00:00 2026-06-15T12:59:53+00:00

I am trying to learn PHP, and i just moved to Exceptions and when

  • 0

I am trying to learn PHP, and i just moved to Exceptions and when i
try a example from

http://php.net/manual/en/language.exceptions.php

Example #2 Exception handling with a finally block

And i get an error

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\test\filename.php on line 13

<?php
function inverse($x) {
    if (!$x) {
        throw new Exception('Division by zero.');
    }
    else return 1/$x;
}

try {
    echo inverse(5) . "\n";
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
} finally {
    echo "First finally.\n";
}

try {
    echo inverse(0) . "\n";
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
} finally {
    echo "Second finally.\n";
}

// Continue execution
echo 'Hello World';
  • 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-15T12:59:54+00:00Added an answer on June 15, 2026 at 12:59 pm

    The finally block of try-catch was added in PHP 5.5 which is still in development so the likely reason it isn’t working for you is because you are using PHP 5.4 or earlier.

    You won’t be able to use finally unless they backport it into an earlier PHP version or you are on a 5.5 release.

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

Sidebar

Related Questions

I'm trying to learn from the http://jquery.malsup.com/form/#getting-started example. When I click submit, the alert
I'm trying to learn how to use the library vcglib (http://vcg.sourceforge.net/index.php/Main_Page) but I'm having
I am trying to learn more about the PHP function sprintf() but php.net did
I´m trying to learn C#, coming from a Python/PHP background, and I´m trying to
I'm trying to learn C from a Ruby/PHP/Java background, and I've found that you
I'm PHP developer but trying to learn ASP.NET MVC. In PHP when i need
I am trying to learn PHP classes so I can begin coding more OOP
i'm trying to learn php/mysql. inserting data into mysql works fine but inserting those
Trying to learn about php's arrays today. I have a set of arrays like
I am developing in C++ and is trying to learn some php. I was

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.