You are here: Re: name of the calling function « PHP Language « IT news, forums, messages
Re: name of the calling function

Posted by Kimmo Laine on 09/21/05 12:53

"Anze" <anzenews@volja.net> wrote in message
news:1T9Ye.317$h6.109140@news.siol.net...
> Hi all!
>
> Is it possible (in PHP4 and PHP5) to get the filename and line number of
> the
> call to the current function? I need it for debugging purposes:
>
> function query_DB($sql) {
> ... // do a query here
>
> if ($query_failed)
> write_to_log($fail_reason."; Called from ".$__CALLING_FILE__.
> " line: ".__CALLING_LINE__);
>
> ... // return result
> }
>
> __FILE__ and __LINE__ are not good enough - they will always return the
> address of query_DB() function, but I need the address where the function
> was called (this is where the error comes from).


Looks like you need debug_backtrace() (available since PHP4.3)
http://www.php.net/manual/en/function.debug-backtrace.php

In short: it traces the origin of the function call and generates an array
of the trace.

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
antaatulla.sikanautaa@gmail.com.NOSPAM.invalid

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация