我收到以下錯誤信息:PHP在同一個文件中重新聲明,但只在聲明。錯誤?
[Wed Sep 21 21:19:46 2011] [error] [client 127.0.0.1] PHP Fatal error: Cannot redeclare db_get_groups()
(previously declared in /Library/WebServer/Documents/SMICAdmin/databasescripts/db_get_groups.php:4)
in /Library/WebServer/Documents/SMICAdmin/databasescripts/db_get_groups.php on line 24,
referer: http://localhost/SMICAdmin/index.php
正如你可以看到,該錯誤信息抱怨說,同樣的功能,db_get_groups(),在同一個腳本兩次。但它不是,整個文件包括在這裏(db_get_groups.php):
<?php
function db_get_groups($dbconnection){ //Line 4
$query = "SELECT id FROM groups";
$result = mysqli_query($dbconnection, $query);
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
$grouplist = Array();
foreach ($rows as $key => $value) {
error_log(" Value -> ".$value['id']);
$grouplist[] = $value['id'];
}
return $grouplist;
} //Line 24
?>
在做在整個項目中的「db_get_groups」的搜索我只能找到下面的唯一聲明和文件在兩個inluded其他文件的使用。
我確實試圖找到我是否以某種方式多次導入某個文件,找不到任何文件。
什麼問題,我該如何解決?感覺真的連接這一個...
你確定你的文件沒有在index.php中包含兩次嗎? –
要了解@AlanMoore說的話,試試'include_once(db_get_groups.php)' –
function_exists(db_get_groups)的結果是什麼;? –