Dynamically generate classes at runtime in php?

后端 未结 10 1052
一向
一向 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条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 15:44

    This is almost certainly a bad idea.

    I think your time would be better spent creating a script that would create your class definitions for you, and not trying to do it at runtime.

    Something with a command-line signature like:

    ./generate_classes_from_db   [tables] [output dir]
    

提交回复
热议问题