Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP exception is caught, but error message still appears
    primarykey
    data
    text
    <p>I use some code from the PHP manual to make an exception test, but I get some weird message.</p> <p>Here it is the code:</p> <pre><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-&gt;getMessage(), "\n"; } // Continue execution echo 'Hello World'; </code></pre> <p>And here it is the output:</p> <pre><code>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 </code></pre> <p>It's strange that although the exception has been caught, the exception message is still on...</p> <p>Some of my local settings in php.ini:</p> <pre><code>error_reporting = E_ALL &amp; ~E_DEPRECATED display_errors =On display_startup_errors = Off log_errors = Off ...... html_errors = On </code></pre> <p>My notebook:</p> <pre><code>ubuntu11.04 mysql Ver 14.14 Distrib 5.1.54 PHP 5.3.5-1 </code></pre> <p><strong>Update(2012.1.16)</strong> 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:</p> <pre><code>xdebug_disable();//put it on the header of your code,like cofig file. </code></pre> <p><a href="http://xdebug.org/docs/all_functions#xdebug_disable" rel="nofollow noreferrer" title="xdebug functions reference">more details</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload