Answer the question
In order to leave comments, you need to log in
What is the best way to avoid the redeclare error?
The function is called in a loop.
A class is declared inside the function, as a result, the error "Cannot redeclare class"
If I take the class out of the function, will it stop seeing it? Does the function see variables either only accepted or declared inside it? How to properly design such a case? Convert the class to a function too?
Answer the question
In order to leave comments, you need to log in
You are doing some nonsense.
According to a normal class file, apart from the class itself, nothing else should contain.
Next, you autoload classes according to PSR-4 and forget about Cannot redeclare class for the rest of your life.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question