Throw an exception and then output the number of the line on which it was thrown:
<?php
try {
throw new Exception("An error occurred");
} catch(Exception $e) {
echo $e->getLine();
}
?>
Try it Yourself »
The getLine()
method returns the line number of the line of code which threw the exception.
$exception->getLine()
Return Value: | Returns an integer |
---|
Read more about Exceptions in our PHP Exceptions Chapter.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!