php dynamic class inheritance -


i know can generate class @ runtime executing

$obj = (object)array('foo' => 'bar');+ 

this way can use

echo $obj->foo; //bar 

what if want make $obj inherits existing class?

what wanna achive: i'm forking paris project on github (https://github.com/balanza/paris). it's active record class. wonder need declare class every object, if it's empty:

class user extends model{} 

i guess might use dynamic object avoid boring stuff.

you eval('class user extends model{}') not idea. really, should create class in file, opcode caching work properly, can version tracked, etc etc.

tl;dr: define model class, right thing do™.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -