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
Post a Comment