我目前有一個PHP函數,我需要從不同的文件調用來填充一個Javascript變量。我可以很好地填充JavaScript變量。調用PHP函數然而,當我得到一個錯誤消息,指出如何正確調用PHP函數?
使用未定義的常量getEstGrid的 - 假設 'getEstGrid' 在 phpcom/DB/estimatesCom.php </b>標籤上線29
這是我包括具有的功能文件:
<?php include 'phpcom/db/estimatesCom.php';?>
這裏是我打電話的功能:
<?php echo getEstGrid($resultsE); ?>
功能代碼:
function getEstGrid($resultsE){//<--This is the variable passed to the function
if ($resultsE->num_rows > 0) { //<--- Check to see if the variable is greater than zero
$rows = array(); //<--- Create an empty array calls "rows"
while ($r = $resultsE->fetch_assoc()){//<--- While the database records are being returned create a variable called "r" and assign DB record.
$rows[] = $r; //<-- assign each DB record row to the array.
}
$data = array('Estimates' => $rows);//<--- Create a variable an assing the array to it.
}
//header("Content-Type: application/json;charset=utf-8");
echo json_encode($data, true);//<--- Endode the "data" variable to a JSON format.
return getEstGrid;//<--- Return the created fucntion.
}
如果任何人都可以在這方面幫助我將不勝感激。
函數定義是什麼樣的? – Kai
看起來你沒有一個名爲'getEastGrid()'的函數。 –
那麼guessCom.php中的第29行是什麼? – Liren