📜 ⬆️ ⬇️

Getting the name of a subclass

There is the following code:

class Model_Base {
public static function find() {
return get_class();
}
}

class Product extends Model_Base { }

echo Product::find();


* This source code was highlighted with Source Code Highlighter .


After executing the code, we get: “Model_Base”.
')
Is it possible in PHP 5.2 to get the name of a subclass (ie, Product) in the static find () method of the Model_Base class?
Or can this be done only in PHP 5.3?
Any solution will suit me, even if it’s a dirty hack)

Source: https://habr.com/ru/post/44176/


All Articles