class - Define classes based on variables in PHP -
so, i'm developing webapp under own mvc structure , controller classes defined inside own files, e.g.: homecontroller defined inside homecontroller.php. question is: possible automatically define class based on file name? like, tried catch filename using file, define class based on that.
$path = __file__; // "c:.../app/controller/homecontroller.php" $array = explode(directory_separator, $path); array_pop($array); // in order remove "homecontroller.php" $class = end($array); // controller $classname = 'home'.$class; class $classname {} // not working, possible or not?
short answer: no.
long answer: cannot way want to. create code creates php file , generates boilerplate class template.
Comments
Post a Comment