How can I “cancel” a class that has been declared

I have a complete system for creating forms. There are many different types of questions, and I have to check the correctness of the answer that the person made.

All types of questions have their own class, which is always called ItemClass, and this class is in its own file.

Every time a question is asked, I include a file and a problem arises: I have to check different types of questions in one PHP file. And then an error appears - ItemClass is already declared.

Is there a way to undo a class?

+5
source share
4 answers

, , , : (ynItemClass, markItemClass,...), a,

$it = $item->item_type."ItemClass";
$test = new $it($smarty);

!!

! Dominik

0

, "" .

, : / , , , ItemClass.


, :

  • ItemClass_Type1 itemclass_type1.php
  • ItemClass_Type2 itemclass_type2.php

.. - , / .


( , runkit "undefining a class", , , - )

+6

.

, "unset"

, namespaces ?

+4

. .
, / (1) factory pattern ( 2) .

+1

All Articles