array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ru', ), 'this' => array ( 0 => 'exception.tostring.php', 1 => 'Exception::__toString', ), 'up' => array ( 0 => 'class.exception.php', 1 => 'Exception', ), 'prev' => array ( 0 => 'exception.gettraceasstring.php', 1 => 'Exception::getTraceAsString', ), 'next' => array ( 0 => 'exception.clone.php', 1 => 'Exception::__clone', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ru', 'path' => 'language/predefined/exception/tostring.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
Exception::__toString — Строковое представление исключения
У этой функции нет параметров.
Возвращает исключение в виде строки (string).
Пример #1 Пример использования Exception::__toString()
<?php
try {
throw new Exception("Какое-нибудь сообщение об ошибке");
} catch(Exception $e) {
echo $e;
}
?>
Вывод приведённого примера будет похож на:
exception 'Exception' with message 'Какое-нибудь сообщение об ошибке' in /home/bjori/tmp/ex.php:3 Stack trace: #0 {main}