As we all know, in C language, we can use #define a MACRO name and determine whether the header file needs to be referenced by checking whether the MACRO name is defined. There is the same problem in PHP, for example: A refers to B, C, B refers to C. If no measures are taken, C will be quoted twice. This may cause some strange problems.
I solved this problem by defining a global variable and checking whether the variable is defined. The method is very simple, similar to C.
For this global variable, I recommend using the naming rule of [user_packages] [headfilename]. Maybe this would be better.
if (!empty($GLOBALS[BOOKSTALLS][GLOBALDEFINE])) return;
$GLOBALS[BOOKSTALLS][GLOBALDEFINE] = true;
class bookstalls {...
};
In addition, try to use require_once "headfiles.php"; in the main program to avoid repeated references.
This method has been applied in our development team, and the effect is quite good. You might as well do the same.