Dynamically generate classes at runtime in php?

后端 未结 10 1051
一向
一向 2020-12-09 15:06

Here\'s what I want to do:

$clsName = substr(md5(rand()),0,10); //generate a random name
$cls = new $clsName(); //create a new instance

function __autoload(         


        
10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 15:21

    I have created a package that dynamically creates classes/interfaces/traits... and stores them into a file you can then just include the created file to be able to use your class

    package : https://packagist.org/packages/kanel/enuma

提交回复
热议问题