Jump to content

Command For Line Number, Filename, Traceback


Guest cfican

Recommended Posts

Guest cfican

Is there a function in php that will allow me to look at the function call stack, line numbers, file names, etc?? TIA

Link to comment
Share on other sites

PHP is a very high-level language, you don't have access to it's implementation of the call stack, if it has one. (Why worry anyway? PHP is single-threaded.)You can read a directoy using glob(). I don't know what "line number" function you are looking for. I don't think there is a traceback function in PHP, the best you can probably get without a custom system-level implementation is the $_SERVER['REMOTE_ADDR'] index.

Link to comment
Share on other sites

Guest cfican

I probably misstated my question. I am making changes to an inherited large php program, and I can’t find out where a particular function is called from. When php gives and error, it provides the file name and the line number where the error occurs. I would like to get that same information in a few lines of code added to a function to be able to trace what line, file, called the function. I thought I have seen that in php, outside the error handling function.

Pseudo code Function actup() {  Array call_stack =  called_by();

Link to comment
Share on other sites

The __FILE__ and __LINE__ constants will hold whatever file and line number they appear on. The __FUNCTION__ and __CLASS__ constants hold the function and class name. Unfortunately, these aren't very useful for a debugging or logging function because they will all point to the debug function as the location. I don't think there's a way for a function to get information about where it was called from, other than the backtrace.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...