strip_tags() expects parameter 1 to be string - error

前端 未结 1 527
刺人心
刺人心 2021-01-27 04:39

After months of use my application form suddenly stopped with this error:

Warning: strip_tags() expects parameter 1 to be string, array given in /home/useraccoun         


        
1条回答
  •  [愿得一人]
    2021-01-27 05:00

    Well, it's obvious - your $_POST[$key] as array and not string. So you need to decide what do do in terms of logic of your application. I can suggest:

    if(is_scalar($_POST['$key']))
    {
       //treat any scalar value as string and do stuff:
       $post->{$key} = trim(strip_tags($_POST[$key]));
    }
    else
    {
       //here you need to decide what to do with such things as arrays
    }
    

    0 讨论(0)
提交回复
热议问题