As you know, in C, we can use # define to define a MACRO name and check whether the MACRO name is defined to determine whether the header file needs to be referenced. The same problem also exists in PHP. For example, A references B, C, and B to C. If no action is taken, C will be referenced twice. This may cause some strange problems.
I define a global variable and check whether the variable is defined to solve this problem. The solution is very simple, similar to C.
I recommend that you use the naming rules of [user_packages] [headfilename] for this global variable. It may be better.
If (! Empty ($ GLOBALS [bookstils] [GLOBALDEFINE]) return;
$ GLOBALS [bookstils] [GLOBALDEFINE] = true;
Class bookstils {...
};
In addition, 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 may wish to do the same.