【问题标题】:PHP: 'syntax error, unexpected T_STRING' [duplicate]PHP:'语法错误,意外的 T_STRING' [重复]
【发布时间】:2023-03-20 04:45:01
【问题描述】:

PHP 解析错误:语法错误,意外的 '=' 不确定最好的解决方法。尝试删除空格。为了隐私,我更改了我的电子邮件地址。

<?php

if(isset($_POST['submit'])) {
$msg = 'contact:'.$_POST['contact'] ."\n"
    .'email:'.$_POST['email'] ."\n"
    .'epk:'.$_POST['epk'] ."\n"
    .'links:'.$_POST['links'] ."\n"
    .'genre:'.$_POST['genre'] ."\n"
    .'years:'.$_POST['years'] ."\n"
    .'label:'.$_POST['label'] ."\n"
    .'drop:'.$_POST['drop'] ."\n"
    .'grant:'.$_POST['grant'] ."\n"
    .'agree:'.$_POST['agree'] ."\n"
  mail('name@mysite.com','EPK application',$msg);
  header ('location:thanks.htm');   
  } else {  
  header ('location:application.htm') ;
  exit(0);  
 }


?>

【问题讨论】:

  • 您在该行的末尾缺少一个分号结尾,其中包含同意以完成 $msg 语句。

标签: php formmail


【解决方案1】:

缺少分号。我发表评论以突出在评论中难以描述的位置:

<?php

if(isset($_POST['submit'])) {
$msg = 'contact:'.$_POST['contact'] ."\n"
    .'email:'.$_POST['email'] ."\n"
    .'epk:'.$_POST['epk'] ."\n"
    .'links:'.$_POST['links'] ."\n"
    .'genre:'.$_POST['genre'] ."\n"
    .'years:'.$_POST['years'] ."\n"
    .'label:'.$_POST['label'] ."\n"
    .'drop:'.$_POST['drop'] ."\n"
    .'grant:'.$_POST['grant'] ."\n"
    .'agree:'.$_POST['agree'] ."\n"; // <--- Semi-colon
  mail('name@mysite.com','EPK application',$msg);
  header ('location:thanks.htm');   
  } else {  
  header ('location:application.htm') ;
  exit(0);  
 }


?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    相关资源
    最近更新 更多