In PHP, you can use the getLine() function in the exception handling class Exception to display the number of error lines. This function can return the line number of the code where the error occurred. The syntax is "final public Exception::getLine() :int".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
PHP provides a built-in exception handling class— —Exception, the member function getLine() in this class can return the code line number where the error occurred
Exception::getLine — Get the line number in the file where the created exception is located
Syntax:
final public Exception::getLine(): int
Return value: Returns the line number of the code where the error occurred.
Example:
<?php header("Content-type:text/html;charset=utf-8"); try { throw new Exception("一些错误消息"); } catch(Exception $e) { echo "错误发生在第: " . $e->getLine()."行"; } ?>
Output result:
PHP Video Tutorial》
The above is the detailed content of How to display the number of error lines in php. For more information, please follow other related articles on the PHP Chinese website!