I would like to create a php class by a variable name something like
$name = "class_name".time().mt_rand();
class $name {
function function_one() {
echo "LOL";
}
}
$name::function_one();
I want an answer without using no eval.
I would like to create a php class by a variable name something like
$name = "class_name".time().mt_rand();
class $name {
function function_one() {
echo "LOL";
}
}
$name::function_one();
I want an answer without using no eval.
If you need to dynamically define classes, then use Anonymous Classes, otherwise you should be giving your classes fixed names, not based on random variable values
$class = new class() {
function function_one() {
echo "LOL";
}
};
$class->function_one();
But why do you need to use dynamically defined classes like this?
$time = time(); $class{$time} = new class() {