1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 06:21:12 +02:00
Files
archived-php-src/pear/tests/pear_error_callback.phpt
Stig Bakken 971f8b0881 @Added a more configurable error reporting interface to DB.
Added a more configurable error reporting interface to DB.
Also added some more tests, and moved the DB tests to pear/DB/tests.
#Usage example that prints and exits on every error:
#$dbh = DB::connect($dsn);
#$dbh->setErrorHandling(PEAR_ERROR_DIE);
#
#Example with plain callback function:
#$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "errorHandler");
#
#Example with object callback function:
#$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($obj, "errorHandler"));
#
#Handler functions/methods are called with the error object as a parameter.
#
2000-09-09 02:39:56 +00:00

33 lines
856 B
PHP

--TEST--
PEAR_Error in callback mode
--SKIPIF--
--FILE--
<?php
require_once "PEAR.php";
function error_function($obj) {
print "this is error_function reporting: ";
print $obj->toString();
print "\n";
}
class myclass {
function error_method($obj) {
print "this is myclass::error_method reporting: ";
print $obj->toString();
print "\n";
}
}
$obj = new myclass;
new PEAR_Error("errortest1", 0, PEAR_ERROR_CALLBACK, "error_function");
new PEAR_Error("errortest2", 0, PEAR_ERROR_CALLBACK,
array(&$obj, "error_method"));
?>
--GET--
--POST--
--EXPECT--
this is error_function reporting: [pear_error: message="errortest1" code=0 mode=callback level=notice prefix="" prepend="" append=""]
this is myclass::error_method reporting: [pear_error: message="errortest2" code=0 mode=callback level=notice prefix="" prepend="" append=""]