我目前有一个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