Added exception handling example.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@49985 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Sebastian Bergmann 2001-06-22 05:56:56 +00:00
parent 37af9e435d
commit 68563fe6a3

View file

@ -181,6 +181,32 @@
<funcdef>exception <function>java_last_exception_get</function></funcdef>
</funcprototype>
</funcsynopsis>
<para>
The following example demonstrates the usage of Java's exception
handler from within PHP:
<example>
<programlisting role="php">
<?php
$stack = new Java("java.util.Stack");
$stack-&gt;push(1);
// This should succeed
$result = $stack->pop();
$ex = java_last_exception_get();
if (!$ex) print "$result\n";
// This should fail (error suppressed by @)
$result = @$stack-&gt;pop();
$ex = java_last_exception_get();
if ($ex) print $ex->toString();
// Clear last exception
java_last_exception_clear();
?>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
</reference>