Exception::__toString

(PHP 5, PHP 7, PHP 8)

Exception::__toStringString representation of the exception

Опис

public Exception::__toString(): string

Returns the string representation of the exception.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

Returns the string representation of the exception.

Приклади

Приклад #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}

Прогляньте також