Re: Caller's __LINE__

From: Date: Wed, 28 Feb 2001 17:22:50 +0000
Subject: Re: Caller's __LINE__
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-42036@lists.php.net to get a copy of this message
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 <jpm@phpbrasil.com> 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 --

« previous php.general (#42036) next »