【问题标题】:Parse error: syntax error, unexpected ',', expecting variable (T_VARIABLE)解析错误:语法错误,意外的 ',',期望变量 (T_VARIABLE)
【发布时间】:2017-08-31 16:40:20
【问题描述】:

我在定义函数和来自 error_reporting(E_ALL); 时遇到错误

有错误Parse error: syntax error, unexpected ',', expecting variable (T_VARIABLE) in C:\xampp\htdocs\bs4\func.php on line 4

这是我的代码

<?php
error_reporting(E_ALL);
require_once "condb.php";
function noproblem(time,suggest,phone,eat,problem){ // Here is line 4

  $sql="insert into data(time,suggest,phone,eat,problem) values(?,?,?,?,?)";
  $stmt=$cn->prepare($sql);
  $stmt->bindParam("1",time);
  $stmt->bindParam("2",suggest);
  $stmt->bindParam("3",phone);
  $stmt->bindParam("4",eat);
  $stmt->bindParam("5",problem);

  try {
    $stmt->execute();
    echo "ok!";
  } catch (Exception $e) {
    echo $e->getTraceAsString();
  }
}
?>

【问题讨论】:

    标签: php pdo php-parse-error


    【解决方案1】:

    在 PHP 中变量必须以 $ 开头:

    function noproblem($time,$suggest,$phone,$eat,$problem){
    

    这同样适用于示例中的所有其他变量。

    【讨论】:

      【解决方案2】:

      变量以“$”符号开头。

      【讨论】:

        【解决方案3】:

        如果您确定所有变量都以“$”符号开头,则可能是您的 PHP 版本。

        【讨论】:

          猜你喜欢
          • 2018-12-16
          • 2018-07-25
          • 1970-01-01
          • 2012-05-11
          • 1970-01-01
          • 2021-11-03
          • 2015-11-19
          • 2019-01-05
          • 1970-01-01
          相关资源
          最近更新 更多