php标题("位置:$ _SERVER [HTTP_REFERER]");

时间:2016-11-21 02:24:58

标签: php

我对此声明有疑问:

header("Location: $_SERVER[HTTP_REFERER]");

我收到以下错误:

语法错误:意外'位置(T_STRING)' 这是php文件:

foreach($_POST['mentalState'] as $mentalState)
($mentalState1=$mentalState . ',' . $mentalState1);

}
else{

    $mentalState1="no information";
}


if(!empty($_POST['mentalState2'])){
// Loop to store and display values of individual checked checkbox.
foreach($_POST['mentalState2'] as $mentalState)
($mentalState2=$mentalState . ',' . $mentalState2);
}

else{

    $mentalState2="no information";
}


if(isset($mentalState1) && isset($_POST['action']) && isset($mentalState2)) {
    $data = $mentalState1 . '-' . $_POST['action'] . '-' . $mentalState2 . "\n;
    $ret = file_put_contents('matrix.txt', $data, FILE_APPEND | LOCK_EX);
    if($ret === false) {
        die('There was an error writing this file');
    }

  else {
  header("Location: $_SERVER[HTTP_REFERER]");
}
}

else {
   die('no post data to process');
}

}

P.S。我正在开发cloud9 p.2。我试图查找现有的答案,但不是它们似乎对我有用。

0 个答案:

没有答案