2003-10-27 12:52:37 +00:00
|
|
|
--TEST--
|
|
|
|
Test 3: Exception Test
|
|
|
|
--SKIPIF--
|
|
|
|
<?php require_once('skipif.inc'); ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$dom = new domdocument;
|
|
|
|
$dom->load(dirname(__FILE__)."/book.xml");
|
|
|
|
$rootNode = $dom->documentElement;
|
|
|
|
print "--- Catch exception with try/catch\n";
|
|
|
|
try {
|
|
|
|
$rootNode->appendChild($rootNode);
|
|
|
|
} catch (domexception $e) {
|
|
|
|
var_dump($e);
|
|
|
|
}
|
|
|
|
print "--- Don't catch exception with try/catch\n";
|
|
|
|
$rootNode->appendChild($rootNode);
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
--- Catch exception with try/catch
|
2008-07-14 11:47:44 +00:00
|
|
|
object(DOMException)#%d (%d) {
|
2007-11-02 19:41:12 +00:00
|
|
|
["message":protected]=>
|
2004-05-20 21:13:14 +00:00
|
|
|
string(23) "Hierarchy Request Error"
|
2007-11-02 19:41:12 +00:00
|
|
|
["string":"Exception":private]=>
|
2004-05-20 21:13:14 +00:00
|
|
|
string(0) ""
|
2007-11-02 19:41:12 +00:00
|
|
|
["file":protected]=>
|
2005-04-08 12:18:57 +00:00
|
|
|
string(%d) "%sdom003.php"
|
2007-11-02 19:41:12 +00:00
|
|
|
["line":protected]=>
|
2004-05-20 21:13:14 +00:00
|
|
|
int(8)
|
2007-11-02 19:41:12 +00:00
|
|
|
["trace":"Exception":private]=>
|
2005-06-22 15:30:14 +00:00
|
|
|
array(1) {
|
|
|
|
[0]=>
|
|
|
|
array(6) {
|
|
|
|
["file"]=>
|
2005-06-23 10:57:52 +00:00
|
|
|
string(%d) "%sdom003.php"
|
2005-06-22 15:30:14 +00:00
|
|
|
["line"]=>
|
|
|
|
int(8)
|
|
|
|
["function"]=>
|
|
|
|
string(11) "appendChild"
|
|
|
|
["class"]=>
|
2005-06-23 09:25:00 +00:00
|
|
|
string(7) "DOMNode"
|
2005-06-22 15:30:14 +00:00
|
|
|
["type"]=>
|
|
|
|
string(2) "->"
|
|
|
|
["args"]=>
|
|
|
|
array(1) {
|
|
|
|
[0]=>
|
|
|
|
object(DOMElement)#%d (0) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-20 21:13:14 +00:00
|
|
|
}
|
2008-07-13 21:22:55 +00:00
|
|
|
["previous":"Exception":private]=>
|
|
|
|
NULL
|
2008-07-14 11:47:44 +00:00
|
|
|
["code"]=>
|
|
|
|
int(3)
|
2003-10-27 12:52:37 +00:00
|
|
|
}
|
|
|
|
--- Don't catch exception with try/catch
|
|
|
|
|
2004-03-29 20:54:13 +00:00
|
|
|
Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
|
2003-10-27 12:52:37 +00:00
|
|
|
Stack trace:
|
2005-06-23 09:25:00 +00:00
|
|
|
#0 %sdom003.php(13): DOMNode->appendChild(Object(DOMElement))
|
2005-06-22 15:30:14 +00:00
|
|
|
#1 {main}
|
2003-12-11 13:36:42 +00:00
|
|
|
thrown in %sdom003.php on line %d
|