php-src/tests/lang/039.phpt

44 lines
698 B
Plaintext
Raw Permalink Normal View History

2004-06-27 21:28:01 +08:00
--TEST--
Catch Interfaces
--FILE--
<?php
interface Catchable
{
}
class MyException extends Exception implements Catchable
{
2020-02-04 05:52:20 +08:00
function __construct($errstr, $errno, $errfile, $errline)
{
parent::__construct($errstr, $errno);
$this->file = $errfile;
$this->line = $errline;
}
2004-06-27 21:28:01 +08:00
}
function Error2Exception($errno, $errstr, $errfile, $errline)
{
2020-02-04 05:52:20 +08:00
throw new MyException($errstr, $errno, $errfile, $errline);
2004-06-27 21:28:01 +08:00
}
$err_msg = 'no exception';
set_error_handler('Error2Exception');
try
{
2020-02-04 05:52:20 +08:00
$con = fopen('/tmp/a_file_that_does_not_exist','r');
2004-06-27 21:28:01 +08:00
}
catch (Catchable $e)
{
2020-02-04 05:52:20 +08:00
echo "Catchable\n";
2004-06-27 21:28:01 +08:00
}
catch (Exception $e)
{
2020-02-04 05:52:20 +08:00
echo "Exception\n";
2004-06-27 21:28:01 +08:00
}
?>
--EXPECT--
2004-06-27 21:28:01 +08:00
Catchable