2017-08-31 648 views
-6

我有錯誤的定義,功能和error_reporting(E_ALL);解析錯誤:語法錯誤,意外「」,期待變量(T_VARIABLE)

有錯誤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(); 
    } 
} 
?> 

回答

1

在PHP變量必須開始以$:

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

同樣適用於示例中的所有其他變量。

相關問題