Is there a way to get the name of a particular class/object/file which has called a particular method from within the method itself??
Basically I want only a particular class to be able to call a particular method of another class without extending from one to the other etc.
Is there a way to get name of class which calls a method?
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
I think your best bet would be to send it as a method argument:
Code: Select all
$someClass::methodName('arg1',__CLASS__);- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Re: Is there a way to get name of class which calls a method
You can use debug_backtrace, but the whole thing seems quite odd to me. Care to explain why you think you need this?mcccy005 wrote:Is there a way to get the name of a particular class/object/file which has called a particular method from within the method itself??
Basically I want only a particular class to be able to call a particular method of another class without extending from one to the other etc.
Main reason is that the method I'm using allows certain fields and corresponding values to be deleted from a generated sql query. I only want access to this particular method from one particular class.
Thats primarily why.
I did read something about that backtrace in other posts whilst searching but everyone said it was a bit dodgy so figured I'd try my luck with this post.
Thats primarily why.
I did read something about that backtrace in other posts whilst searching but everyone said it was a bit dodgy so figured I'd try my luck with this post.