Is it possible to use some prototype inheritance in PHP , as it is implemented in JavaScript ?
This question came to my mind only out of curiosity, and not that I should realize such a thing and go against classical inheritance. This is just an interesting area to explore.
Are there prebuild functions for combining the classic inheritance model in PHP with some kind of Prototypal inheritance with a combination of anonymous functions?
Say I have a simple class for UserModel
class UserModel implements PrototypalInheritance { // setters, getters, logic.. static public function Prototype () {} } $user = new UserModel(); UserModel::prototype()->getNameSlug = function () { return slugify($this->getUserName()); } echo $user->getNameSlug();
javascript inheritance prototype php prototypal-inheritance
Juraj blahunka
source share