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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:21:48+00:00 2026-05-28T03:21:48+00:00

I use some code from the PHP manual to make an exception test, but

  • 0

I use some code from the PHP manual to make an exception test, but I get some weird message.

Here it is the code:

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

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

// Continue execution
echo 'Hello World';

And here it is the output:

0.2
( ! ) Exception: Division by zero. in /var/www/OOPlearing/slash.php on line 10Call Stack#TimeMemoryFunctionLocation10.0002330188{main}(  )../slash.php:020.0002330232inverse( $x = 0 )../slash.php:17Dump $_SERVER$_SERVER['HTTP_HOST'] =string 'localhost' (length=9)$_SERVER['SERVER_NAME'] =string 'localhost' (length=9)Dump $_GETVariables in local scope (#2)$x =int 0
Caught exception: Division by zero.Hello World

It’s strange that although the exception has been caught, the exception message is still on…

Some of my local settings in php.ini:

error_reporting = E_ALL & ~E_DEPRECATED
display_errors =On
display_startup_errors = Off
log_errors = Off
......
html_errors = On

My notebook:

ubuntu11.04
mysql  Ver 14.14 Distrib 5.1.54
PHP 5.3.5-1

Update(2012.1.16) It’s the xdebug extension that resulted in such error outputs. The xdebug default shows stack traces on error conditions. For those who want to disable it can do below instruction:

xdebug_disable();//put it on the header of your code,like cofig file.

more details

  • 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-28T03:21:48+00:00Added an answer on May 28, 2026 at 3:21 am

    When you try/catch() a block of code then you wont get a fatal error of “Uncaught exception”. A fatal error will cause the script to stop executing at the point of the error. Since you caught the exception, it did what you told it to: Echo the string + error message, then it continued execution to “Hello World!”. If anything your error reporting is more verbose due to your INI settings, like the stack trace printout.

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

Sidebar

Related Questions

i use some code for inline cell editing from Apples TaggedLocations Example and im
is there some ruby code I can use to install a gem from a
From some old c++ code im trying to use a com dll, it works
I use this bit of code to feed some data i have parsed from
I use the bellow code to load the main menu elements from some CMS,
I am trying to use some pinvoke code to call a C function. The
I'm trying to use some off-the-shelf PHP code in RHEL5 which requires the sqlite
So I am trying to execute some script from my php code. That lives
I use the JQuery dialog and from the PHP I can build some add-in
I would like to use some code written in python (it uses built in

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.