Daniel Li
Daniel Li

Reputation: 397

Get the file and line being called on php?

<?php
//lets say one of these files have the function test();
include 'a.php';
include 'b.php';
include 'c.php';
include 'd.php';

test();
?>

How can I find out which file and line function test() is being called at? (without opening the files) Thanks

Upvotes: 0

Views: 36

Answers (1)

Martin
Martin

Reputation: 2028

You can use reflection with PHP :

$func = new ReflectionFunction('test');
echo $func->getFileName();
echo $func->getStartLine();

Upvotes: 1

Related Questions