我该如何“取消"设置?一个已经声明的类 [英] How can i "unset" a class that has been declared
问题描述
我有一个完整的表格创建系统.有很多不同的问题类型,我必须检查该人做出的答案是否正确.
I have a complete Form Creation System. There are many different Question Types and I have to check if the answer which the person had made is correct.
所有类型的Questions都有自己的类,该类始终称为ItemClass,并且该类位于其自己的File中.
All types of Questions has its own class will is always called ItemClass and this Class is in its own File.
每次询问问题时,我都会包含文件,这是有问题的:我必须在一个PHP文件中检查不同类型的问题.然后出现错误-ItemClass已经声明.
Everytime a Question is asked I include the File and there is the problem: I have to check different types of Questions in one PHP-File. And then there comes the error - ItemClass already declared.
有什么方法可以取消设置班级吗?
Is there any method to unset a Class?
推荐答案
我测试了您的解决方案,最后得到了一个主意: 我将类重命名为每种类型(ynItemClass,markItemClass等),当我需要Item Type时,请进行以下修改
I tested your solutions and finally I got an Idea: I renamed the Classes to each of it's type (ynItemClass, markItemClass, ...) and when I need a Item Type a made the following
$it = $item->item_type."ItemClass";
$test = new $it($smarty);
它有效!!
祝您有美好的一天! 多米尼克
Have a nice Day! Dominik
这篇关于我该如何“取消"设置?一个已经声明的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!