(PHP 4 >= 4.0.2)
java_last_exception_get — Get last Java exception
Gets last Java exception.
Returns an exception object.
The following example demonstrates the usage of Java's exception handler from within PHP:
Example #1 Java exception handler
<?php
$stack = new Java('java.util.Stack');
$stack->push(1);
// This should succeed
$result = $stack->pop();
$ex = java_last_exception_get();
if (!$ex) {
echo "$result\n";
}
// This should fail (error suppressed by @)
$result = @$stack->pop();
$ex = java_last_exception_get();
if ($ex) {
echo $ex->toString();
}
// Clear last exception
java_last_exception_clear();
?>
此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。
molli at loria dot fr (2001-07-25 03:50:51)
Just pay attention to the return value
of java_last_exception_get(), it's an
exception java object.
To use it just call normal operations on a exception java object:
ex:
@$myconnect->execute(); // @ to avoid warning...
$exc=java_last_exception_get();
$res=$exc->getMessage(); // method call on a exception object...
$exres="class nToxic.Connect:login failed";
$this->assert($res == $exres, "$res == $exres");