Answers for "get all class costants php"

PHP
6

php get class name of this

get_class($this);
Posted by: Guest on March-22-2020
0

php find all subclasses of class

/* Loops through all loaded classes (get_declared_classes()) and
returns an array of subclasses of the provided $parent */
function getSubclasses(string $parent):array {
	return array_reduce(get_declared_classes(), function($subclasses, $class) use ($parent) {
		if (is_subclass_of($class, $parent)) {
			$subclasses[] = $class;
		}
		return $subclasses;
	}, []);
}
Posted by: Guest on July-18-2020

Browse Popular Code Answers by Language