Var mı bir __ sınıfları başlatmasını için sihirli yöntem eşdeğer olsun?

0 Cevap php

__get() sihirli yöntemin işlevselliği tür uygulamak için herhangi bir yolu olup olmadığını görmek isteyen, ancak yeni bir sınıf örneğini çalışırken.

Amacım sahip olmaktır

$foo = new Cat();

Sonuç olarak genel bir nesnenin yaratılmasına neden örneğin,

new Mammal('Cat');

Öyle ki $foo sınıfının bir örneği olacaktır Mammal, denilen sınıf adıyla ('Cat') bir argüman olarak geçirilen Mammal 'nin kurucusu.


Note: The end game I have in mind, for those familiar with Lithium or CakePHP, is to avoid having to define a whole bunch of classes for each different database table. If I did, most would simply be empty, the basic CRUD operations being all that is necessary. Plus, all those includes and class definitions can't be great for overhead. My idea would be to use a single "Model" class to handle most of the generic functions, and I could always create subclasses if I needed more advanced functionality for a specific database table.

0 Cevap