array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'error.tostring.php', 1 => 'Error::__toString', ), 'up' => array ( 0 => 'class.error.php', 1 => 'Error', ), 'prev' => array ( 0 => 'error.gettraceasstring.php', 1 => 'Error::getTraceAsString', ), 'next' => array ( 0 => 'error.clone.php', 1 => 'Error::__clone', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'language/predefined/error/tostring.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7, PHP 8)
Error::__toString — error 的字符串表达
此函数没有参数。
返回 Error 的 string表达形式。
示例 #1 Error::__toString() 例子
<?php
try {
throw new Error("Some error message");
} catch(Error $e) {
echo $e;
}
?>
以上示例的输出类似于:
Error: Some error message in /home/bjori/tmp/ex.php:3 Stack trace: #0 {main}