php - Model Yii2 with ReflectionClass not working -


i have code - working correct (i not have inculde class reflectionclass):

class test {     const type_one = "number one";     const type_two = "number two";      static function getconstants() {           $oclass = new reflectionclass(__class__);         return $oclass->getconstants();     } }     foreach (test::getconstants() $kay => $val):    echo "$kay -- $val <br/>";    endforeach; 

but, when try use reflectionclass in code yii2 gets message

 php fatal error – yii\base\errorexception class 'common\models\reflectionclass' not found 

if there reflection classes in framework or way declare reflectionclass in yii2

because yii2 use namespaces, when call new reflectionclass() php looking class in namespace declare @ beginnig of file, in case namespace common\models; load php's classes need prepend names \. instantiate reflectionclass need write new \reflectionclass(__class__). more in documentation


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -