List Info

Thread: Getting the name of calling function.




Getting the name of calling function.
country flaguser name
United States
2007-10-12 08:41:49
I guess the Subject is a little ambiguos. I want to get the
function
name which calls the target function.

Like

function xxx()
{
 ....
 ....
 yyy(2,3);

}

function zzz()
{
 ....
 yyy(5,6);
 .....

}

function yyy($a,$ab)
{
  ...
 ...
 echo "yyy() has been called by the function -
".$functionname;

}

Now how can I get the name of the function tat calls yyy().

This will be really useful for Error logging purposes.


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Getting the name of calling function.
country flaguser name
United States
2007-10-13 09:22:33
I wonder what it is that you're trying to accomplish. 
Perhaps there's
an easier way?  I can't think of how to do what you're
asking, except
for sending an additional parameter to the function of the
calling
function's name hard-set.  Perhaps if you explain what you
need, we
can come up with a working scenario.

-aaron

On Oct 12, 8:41 am, Shyam Raj <thanash...gmail.com> wrote:
> I guess the Subject is a little ambiguos. I want to get
the function
> name which calls the target function.
>
> Like
>
> function xxx()
> {
>  ....
>  ....
>  yyy(2,3);
>
> }
>
> function zzz()
> {
>  ....
>  yyy(5,6);
>  .....
>
> }
>
> function yyy($a,$ab)
> {
>   ...
>  ...
>  echo "yyy() has been called by the function -
".$functionname;
>
> }
>
> Now how can I get the name of the function tat calls
yyy().
>
> This will be really useful for Error logging purposes.


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Getting the name of calling function.
country flaguser name
United States
2007-10-15 22:27:20

try debug_print_backtrace()

http://us3.php.net/manual/en/function.debug-print
-backtrace.php

note that you will need php5 and if you haven't upgraded to
it yet  
now's a good time 

Phil

On Oct 13, 2007, at 10:22 AM, Aaron Saray wrote:

>
> I wonder what it is that you're trying to accomplish. 
Perhaps there's
> an easier way?  I can't think of how to do what you're
asking, except
> for sending an additional parameter to the function of
the calling
> function's name hard-set.  Perhaps if you explain what
you need, we
> can come up with a working scenario.
>
> -aaron
>
> On Oct 12, 8:41 am, Shyam Raj <thanash...gmail.com> wrote:
>> I guess the Subject is a little ambiguos. I want to
get the function
>> name which calls the target function.
>>
>> Like
>>
>> function xxx()
>> {
>>  ....
>>  ....
>>  yyy(2,3);
>>
>> }
>>
>> function zzz()
>> {
>>  ....
>>  yyy(5,6);
>>  .....
>>
>> }
>>
>> function yyy($a,$ab)
>> {
>>   ...
>>  ...
>>  echo "yyy() has been called by the function -
".$functionname;
>>
>> }
>>
>> Now how can I get the name of the function tat
calls yyy().
>>
>> This will be really useful for Error logging
purposes.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Getting the name of calling function.
country flaguser name
United States
2007-10-20 00:11:07

debug_ backtrace is the function I was looking for. Thanks a
lot..
And adding the function name as a parameter does involve a
lot of
complexity, and we were about to use that idea previously..
But this
seems the perfect fit - the debug_backtrace() .. Tnx a lot.


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


Re: Getting the name of calling function.
country flaguser name
United States
2007-10-20 00:11:36

debug_ backtrace is the function I was looking for. Thanks a
lot..
And adding the function name as a parameter does involve a
lot of
complexity, and we were about to use that idea previously..
But this
seems the perfect fit - the debug_backtrace() .. Tnx a lot.


--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---


[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )