mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
37af9e435d
commit
68563fe6a3
1 changed files with 26 additions and 0 deletions
|
@ -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->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->pop();
|
||||
$ex = java_last_exception_get();
|
||||
if ($ex) print $ex->toString();
|
||||
|
||||
// Clear last exception
|
||||
java_last_exception_clear();
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</reference>
|
||||
|
|
Loading…
Reference in a new issue