1

数か月使用した後、申請フォームが突然停止し、次のエラーが表示されました。

Warning: strip_tags() expects parameter 1 to be string, array given in /home/useraccount/public_html/My_Application.php on line 9

9行目でCookieが始まりますが、それを削除しても、strip_tags行に関連しているようです. なぜこれが突然機能しなくなるのでしょうか? これは何ヶ月も問題なく機能しています。サーバーは でしたが5.3、 へのアップグレードが見られ5.3.26ます。その変化が実際にこれを引き起こしたのでしょうか?

if ($_POST)
{
    session_set_cookie_params(0);
    session_start();
    $post = new stdClass; 
    foreach ($_POST as $key => $val)
    $post->{$key} = trim(strip_tags($_POST[$key]));
    $post->accident_type =$_POST['accident_type'];
    $_SESSION['post']=$post;
} 
more code continued...

どんな助けでも大歓迎です。

4

1 に答える 1

2

まあ、それは明らかです-あなた$_POST[$key]は配列であり、文字列ではありません。したがって、アプリケーションのロジックに関して何をするかを決定する必要があります。私は提案することができます:

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
}
于 2013-09-30T06:36:09.817 に答える