Get class name from file

后端 未结 10 1865
轮回少年
轮回少年 2020-12-08 10:29

I have a php file which contains only one class. how can I know what class is there by knowing the filename? I know I can do something with regexp matching but is there a st

10条回答
  •  渐次进展
    2020-12-08 11:20

    I spent lots of productive time looking for a way around this. From @netcoder's solution its obvious there are lots of cons in all the solutions so far.

    So I decided to do this instead. Since most PHP classes has class name same as filename, we could get the class name from the filename. Depending on your project you could also have a naming convention. NB: This assume class does not have namespace

提交回复
热议问题