On Wed, 28 Feb 2001, Christian Dechery wrote:

>
> >Pass __LINE__ to the function as one of its arguments:
> >
> >  function debuginfo($msg, __LINE__)
> >   {
> >    echo"<b>the message is $msg, at line" . __LINE__ . " </b><br>";
> >   }
>
> that won't work since __LINE__ returns the exact line where it's used... so
> it will always show the line of the function header...
> ____________________________
> . Christian Dechery (lemming)
> . http://www.tanamesa.com.br
> . Gaita-L Owner / Web Developer
>

Okay, simple enough.

Pass __LINE__ as one of its arguments and just use a real variable name on
the function declaration.

function debuginfo($msg, $line_num)
{
  echo"<b>the message is $msg, at line $line_num </b><br>";
}

debuginfo($msg, __LINE__);

This will probably result in a line number that is one integer bigger than
what you want. For instance the error happened on line 40 and you are
actually calling this function on line 42. You can then just substract 2
from that and you will get the real line number. It's ugly, but works (or
should anyway ;).

Regards,
Joao

--
João Prado Maia <[EMAIL PROTECTED]>
http://phpbrasil.com - php com um jeitinho brasileiro
--
Contribua com o projeto de tradução do manual online do PHP
http://phpbrasil.com/traducao.php
--


--
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]

Reply via email to