dynamic class names in php

前端 未结 7 1629
-上瘾入骨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 01:04

    $field_type = 'checkbox';
    $field = new $field_type;
    

    If you need arguments:

    $field_type = 'checkbox';
    $field = new $field_type(5,7,$user);
    

提交回复
热议问题