我将表单数据从一个页面传递到另一个页面.
下面是表单操作的代码,verify.php:
<?php
header("Location: http://domain.com/rd/r.php?&email=<?php echo $_GET['email']; ?>");
?>
Run Code Online (Sandbox Code Playgroud)
但是,我不断收到以下错误:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/thanksfo/public_html/LP/x/verify.php on line 3
Run Code Online (Sandbox Code Playgroud)
知道怎么解决吗?它表示意外的空格或t_encapsed.真的不知道出了什么问题......
双引号字符串的正确语法是:
header("Location: http://domain.com/rd/r.php?&email=$_GET[email]");
Run Code Online (Sandbox Code Playgroud)
您不能<?php在字符串中包含代码,特别是结束时会?>破坏您的语法.
数组语法sans引号仅在此上下文中有效,而不是在纯PHP代码中有效.
正如@Aarolama Bluenk指出的那样,urlencode()建议:
$formatted = urlencode($_GET['email']);
header("Location: http://domain.com/rd/r.php?&email=$formatted");
如果还没有这样做,那么清理电子邮件地址也是明智之举.