PHP Cannot redeclare checkMXservers() pochemu error?

I have a function checkMail() which has the function checkMXservers()
When the function checkMail() define a function checkMXservers() and then use it. But why it says error
Fatal error: Cannot redeclare checkMXservers() (previously declared in ...core.php:45 in ...core.php on line 45

5cf94b330edfe110875213.png5cf94b3fbacdc180303628.png
March 23rd 20 at 19:25
2 answers
March 23rd 20 at 19:27
Solution
https://www.php.net/manual/ru/function.function-ex...

although it is not clear why to describe the function within the function.
Did not understand what the problem. Do not tell more precisely ? - nya.Bogan commented on March 23rd 20 at 19:30
@Psazy, that function is called more than once. - joelle_Rodriguez commented on March 23rd 20 at 19:33
@joelle_Rodriguez, and how to solve the problem if I need to call the function many times ? - nya.Bogan commented on March 23rd 20 at 19:36
@Psazy, remove the function definition from the function or do validation. - joelle_Rodriguez commented on March 23rd 20 at 19:39
March 23rd 20 at 19:29
Solution
This will solve your problem, but I would still recommend to abandon the function definition inside another function.

if (!function_exists("checkMXservers")) {
 function checkMXservers($email, $service) {
...
 } 
}

Find more questions by tags PHP