dynamic class names in php

前端 未结 7 1657
-上瘾入骨i
-上瘾入骨i 2020-12-07 00:31

I have a base class called field and classes that extend this class such as text, select, radio, checkbox, <

7条回答
  •  孤街浪徒
    2020-12-07 00:57

    If you are using a namespace you will need to add it even if you are within the namespace.

    namespace Foo;
    
    $my_var = '\Foo\Bar';
    new $my_var;
    

    Otherwise it will not be able to get the class.

提交回复
热议问题