![]() |
Getting classname where function was called from
How would I get the classname of a class where I called another class's function?
one.php PHP Code:
PHP Code:
You called this from: One, or You called this from: one.php, or You called this from: path/to/file/one.php Is that possible?? |
|
If I'm understanding what you want, it's not as simple as Enfernikus makes out. However, it would be possible: parsing the contents of debug_backtrace might be your best bet.
|
I misunderstood his request, side effect of trying to aid when at work in the midst of a coding frenzy. There's no easy method of doing what you'd like but as Salathe said, debug_backtrace would most likely be your best option.
|
Didn't work quite as I wanted/expected, but thanks for the help!
|
So, have you got the issue solved? Have any more questions? It's nice being thanked, but the thread has been kind of left hanging. :-P
|
Haha, it's solved for the moment but not the way I wanted.
I have an HMVC framework with modules, I wanted so when I load a view, it will first check if the view exists in the current module - IF the view was loaded from a module - and then if not found there check the regular application/views/ folder for the view-file. Kinda like this: modules/welcome/controllers/welcome.php PHP Code:
If not found, check application/views/website/index.php, if found, render it. If not found, check all other modules views directories, if found, render it. If not found, generate error message. On the other hand, if I do like this: application/controllers/welcome.php PHP Code:
If not found, check all modules views directories, if found, render it. If not found, generate error message. All of that is quite simple, takes some work but I can make that work. The thing that complicates it is that I want to be able to load a view from within a view. Like so: modules/welcome/views/website/index.php PHP Code:
If not found, check application/views/footer.php, if found, render it. If not found, check all other modules views directories, if found, render it. If not found, generate error message. I think you get the point.. So somehow I need to check if the factory() call came from a class, if so, check which class, get the name, get the location. If not from a class - but from a viewfile - get the location of that viewfile. |
| All times are GMT. The time now is 04:29 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0