Jump to content

I have a function problem


atbjk

Recommended Posts

hi,

i am trying to give a function a unique name based on where it is called in the page.

for example:
i would call the function like so in a page called test.php lets say the line i call test is 20
test();


this is located in another file function.inc its lines are from 1-3
function test($temp=__LINE__){
    echo $temp;
}

when test echos temp it would give me the line where __LINE__ appears(1).

is there a way to find where a function is executed or how to give it a unique name or how to make __LINE__ dynamic??
Link to comment
https://forums.phpfreaks.com/topic/26165-i-have-a-function-problem/
Share on other sites

Since the __LINE__ constant is in fact for debugging, the only real way to do it (using __LINE__ at least...) is to pass the line as a function parameter.

test.php
[code]
test(__LINE__);
[/code]

function.inc
[code]function test($ln)
{
    echo $ln;
}[/code]

hth...

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.