Exception
PHP 手册

Exception::__toString

(PHP 5 >= 5.1.0)

Exception::__toStringString representation of the exception

说明

public string Exception::__toString ( void )

Returns the string representation of the exception.

参数

This function has no parameters.

返回值

Returns the string representation of the exception.

范例

Example #1 Exception::__toString() example

<?php
try {
    throw new 
Exception("Some error message");
} catch(
Exception $e) {
    echo 
$e;
}
?>

上例的输出类似于:

exception 'Exception' with message 'Some error message' in /home/bjori/tmp/ex.php:3
Stack trace:
#0 {main}


Exception
PHP 手册