Disclaimer: i do not use PHP.
@Jean Victor -- it would help if you (a) explained in more detail WHY you want this and (b) shared some information about your PHP platform.
"Caller Information (C# and Visual Basic)"
"By using Caller Info attributes, you can obtain information about the caller to a method. You can obtain file path of the source code, the line number in the source code, and the member name of the caller. This information is helpful for tracing, debugging, and creating diagnostic tools."
Unfortunately, taking advantage of this feature may be a major challenge in PHP.
First, if you are using a .NET platform, you would have to discover whether the version of PHP that you are using takes advantage of the System.Runtime.CompilerServices Namespace because it "provides functionality for compiler writers who use managed code to specify attributes in metadata that affect the run-time behavior of the common language runtime".
ALTERNATIVE: use an ugly kludge (works only for functions that you own or can modify).
ensure that the first argument of ALL of your functions is a GUID.
# id of myFunctionABC f4f866c7728040a6bf22c7600c64a7ee
function myFunctionABC ($whoCalledMe) {
# Note: myFunctionABC would use the value passed
# via $whoCalledMe in error messages.
# BUT if from within myFuntionABC some other
# function is called, the above GUID would be used:
#
# foo("f4f866c7728040a6bf22c7600c64a7ee")
}
Yes, it's a very, very ugly kludge.
FWIW
edit:
when i wrote this, i was not aware of debug_backtrace.
debug_backtrace should also work on non-.NET platforms.
end edit.