0

I want to be able to get the column of a function call in PHP.

With debug_backtrace(), I can get the line of the function call, but I cannot get the column.

What I want to do is to be able to distinguish two function calls on the same line.

For instance:

function test() {
    //do something with the line/column of the called function.
}

test(); test(); //How to know whether it is the first or second test() which is called?
antoyo
  • 11,097
  • 7
  • 51
  • 82
  • That doesn't seem possible, unless you pass some sort of argument to flag the calls. – Nadh Jul 21 '13 at 16:57
  • 4
    And it is bad practice to put two statements into the same line. – DAG Jul 21 '13 at 17:37
  • @Christian Gärtner: It is only an example. And there are ways to have two function calls in one statement. – antoyo Jul 21 '13 at 21:13
  • Yeah ok. If you using the return values of the function as parameters for another function would be a use case. – DAG Jul 21 '13 at 21:33

2 Answers2

0

You can only identify the function call passing an argument.

Rápli András
  • 3,869
  • 1
  • 35
  • 55
0

I'm not sure what you are trying to do, but this would be a way to differentiate between function calls

function($column){
//do something with $column

}

test(1); test(2);

Edit:

I misread your question, by column you mean (I think) the columnnumber in the source file.

I doubt this is possible because not even syntax errors give back column information.

Further more, debugging tools like xdebug also do not support breaklines at a specific column number.

So it seems doubtful

Richard Deurwaarder
  • 2,023
  • 1
  • 26
  • 40