Jump to content

Command For Line Number, Filename, Traceback


Guest cfican
 Share

Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...