Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

getLine()

Example

Throw an exception and then display the line number where it was thrown.

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

Definition and Usage

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

Syntax

$exception->getLine()

Technical Details

 

Return Value:

Returns an integer value.