G
G
Grigory Vasilkov2015-12-13 17:16:41
PHP
Grigory Vasilkov, 2015-12-13 17:16:41

How to pass the name of the class in which the function is called to another class?

For example, I have a class
class Messages {}
. It has a static method
public static function add() {}
. I accordingly want to know in which class (for example, MainController) the Messages::add() function was called and at the same time not to write like this every time Messages::add($msg, __CLASS__) so that it picks it up automatically.
Tell me please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2015-12-13
@gzhegow

Look at debug_backtrace() .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question