Reputation: 1323
Second time I've ran into this...
I have function foo()
that has a helper function inside called formatStr()
which is used in an array_map()
call. When I call foo()
more than once within a script I get a "Fatal error: Cannot redelcare formatStr()
". Which leads me to believe formatStr()
is not declared locally in the function but globally. Is this true? Can you get around this with function_exists()
?
Thanks
Upvotes: 1
Views: 789
Reputation: 3894
You have a function defined within the foo() function? If so, move it out.
Otherwise, just wrap formatStr() within function_exists()...
if (!function_exists('formatStr'))
{
function formatStr()
{
// Your function code
}
}
Upvotes: 2