Current Location: Home> Function Categories> getLine

getLine

Returns the line number of the line of code that throws the exception.
Name:getLine
Category:Uncategorized
Programming Language:php
One-line Description:Returns the line number of the line of code that throws the exception.

Definition and usage

getLine() method returns the line number of the code that threw the exception.

Related pages

Tutorial: PHP exception

Example

Throw an exception and then output the line number of the code that throws the exception:

 <?php
try {
  throw new Exception ( "An error occurred" ) ;
} catch ( Exception $e ) {
  echo $e -> getLine ( ) ;
}
?>

Try it yourself

grammar

 $exception -> getLine ( )
Similar Functions
Popular Articles