I am using this function and declare display_error(),
but error display on my screen
“Warning: Invalid argument supplied for foreach()”
help with us.
function display_error($nerrors = '')
{
if(isset($nerrors))
{
foreach($nerrors as $err)
{
echo $err->errors['existing_user_login'][0];
}
}
}
Your default parameter to the function is a string and not an array. Change that to an empty array:
You can leave out the
if
, the loop won’t run if the array is empty.