954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Determine in which file a user function is defined?

Hello,

I am familiar with the get_defined_functions() function as a way of listing all of the user defined functions.

Is there a way with PHP to also determine from which file the user function was defined?

Consider the following example. Assume there are three files:
- index.php
- user_functions1.inc.php
- user_functions2.inc.php

contents of user_functions1.inc.php:

<?php
function example_function1() {
    print "hello world 1";
}
?>



contents of user_functions2.inc.php:

<?php
function example_function2() {
    print "hello world 2";
}
?>


contents of index.php:

<?php
include(user_functions1.inc.php);
include(user_functions2.inc.php);
$functions = get_defined_functions();
$user_functions = $functions['user'];
foreach($user_functions as $function) {
	print "$function";
}
?>


output of index.php:

example_function1
example_function2


I would like to use PHP to determine that user functionexample_function1 was defined in the file user_functions1.inc.php

Is this possible?

Thank you.

Dave

metaface
Newbie Poster
11 posts since Jan 2006
Reputation Points: 10
Solved Threads: 1
 

i guess u should do it on each file

w_3rabi
Junior Poster
160 posts since Dec 2006
Reputation Points: 18
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You