Hello. I broke my head, help with advice. I make the generation of XML files through gearman. In the worker, there is a function that loops around the names of the templates and inserts them inside the function. The problem is that the templates, though different, have the same functions (ie, the names of the functions are the same). PHP throws out a Fatal error when the require is repeated.
function regenirationXMLsFreeBoards($job){ //Запуск задачи ... foreach($FreeBoards as $Board){ //Обходим бесплатные доски if(!generationXMLFile($Board)) break; } ... } function generationXMLFile($Board){ $dir = "../../xmls/"; $BoardName = $Board["name"]; $template = $dir."templates/".$BoardName.".php"; require $template; createXML($fileXML); //Эта функция из шаблона $template ... } Those. the first cycle is successful, on the second we fall off due to an error
PHP Fatal error: Cannot redeclare createXML ()
There can be a lot of patterns, while only two. Help advice what to do. It only occurred to me to create a separate function in the calculation that once again causing it, we would lose the previous require. But I forgot that require is inserted into the script at the first use and remains for the entire lifetime of the script.
If something is not clear, ask, I will explain.