Look at this example:
1:
2: write_debug_string("i'm here");
3:
4:
5: write_debug_string("now i'm here");
6:
function write_debug_string($message)
{
echo sprintf("[DEBUG AT LINE %d] %s", get_callers_line(), $message);
}
this should output:
[DEBUG AT LINE 2]: i'm here
[DEBUG AT LINE 5]: now i'm here
so basically, as if passing to the write_debug_string() a hidden parameter =
__LINE__
but i don't want to pass it everytime.
maybe in C language i could have written a macro that passes the __LINE__
for me.
btw, any macros in PHP like in C? (#define xyz...)
""Yasuo Ohgaki"" <[EMAIL PROTECTED]> wrote in message
99sgbp$t8p$[EMAIL PROTECTED]">news:99sgbp$t8p$[EMAIL PROTECTED]...
> Not sure what you really mean.
>
> __LINE__ contains current line number in the script wherever it is used.
So if
> you want caller's line number
>
> function foo($line) {
> echo 'Line number: '. $line;
> }
>
> foo(__LINE__);
>
> You can get the caller's line number. (Line number of foo(__LINE__);)
>
> Regards,
> --
> Yasuo Ohgaki
>
>
> ""elias"" <[EMAIL PROTECTED]> wrote in message
> 99s17u$fd7$[EMAIL PROTECTED]">news:99s17u$fd7$[EMAIL PROTECTED]...
> > Hello,
> >
> > can i make a function that displays the __LINE__ of it's caller?
> >
> > ie:
> >
> > function show_caller_s_line()
> > {
> > echo "my caller's line is:" . __LINE__;
> > }
> >
> > 1: blahblahblah
> > 2: show_caller_s_line()
> > 3: blahblah
> >
> > output should be:
> > my caller's line is: 3
> >
> >
> > is that possible?
> >
> > thanks.
> > -elias
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]