Possible Duplicate:
How to find out where a function is defined?
included php file to know it's file name?
Can I get the filename and line number of the start of a function declaration in PHP?
Say, I have the following code:
1. /**
2. * This function shows the foo bar.
3. */
4. function foo_bar($subject) {
5. echo "Foo bar:\n";
6. if ($subject == "none") {
7. trigger_error("Wrong argument given to 'foo_bar()' in ... on line ....", E_USER_WARNING);
8. }
9. ...
10. }
When I call foo_bar("none"), the function must throw an error like this:
Warning: Wrong argument given to ‘foo_bar()’ in /home/web/mcemperor on line 4.
Can I retrieve the filename and the line number of start of the function declaration?
You’re looking for ReflectionFunction.
It’s that simple… It works for any defined function, whatever one that you passed in to the constructor argument.