如何在带有php的标题上插入带有新行的字符串?以下是我所做的代码,
$error = "Not enough balance to submit. \nBalance available : " . $balance;
header('location:info-page.php?error=' . $error);
当我提交时,会出现此错误:
Warning: Header may not contain more than a single header, new line detected.
更新代码
$error = urlencode("Not enough balance to submit. \nBalance available : ". $baki_cuti);
header('location:permohonan_maklumat_penyelia.php?id='.$pid.'&error='. $error));
页面:permohonan_maklumat_penyelia.php
<?php
if (isset($_GET['error'])) {
echo '<script type="text/javascript">
alert("' .urldecode($_GET['error']) . '");
</script>';
}
?>
收到错误:
permohonan_maklumat_penyelia.php?id=842&error=Not+enough+balance+to+submit.+
Balance+available+%3A+0:112 Uncaught SyntaxError: Invalid or unexpected token