gpt4 book ai didi

php - fatal error : Cannot redeclare getteampoints() (previously declared in

转载 作者:行者123 更新时间:2023-12-04 05:02:45 26 4
gpt4 key购买 nike

这个问题不太可能对任何 future 的访客有帮助;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛适用,visit the help center .




8年前关闭。




得到了以下函数,之前没有在任何地方声明 getteampoints 值。试图遵循其他重新声明错误问题,但没有一个奏效。我该如何解决这个问题?

function getTeamPoints($team)
{
$query = mysql_query("SELECT * FROM Team_comp WHERE t_id='$team'");
$team_array = array();

while($a = mysql_fetch_array($query))
{
$team_array = array( 'home_won' => $a['home_win'],
'home_draw' => $a['home_tie'],
'home_lost' => $a['home_lost'],
'away_won' => $a['away_win'],
'away_draw' => $a['away_tie'],
'away_lost' => $a['away_lost'],
'home_games'=> $a['home_games'],
'away_games'=> $a['away_games']);
}

return $team_array;
}

function calculateTeamPoints($team, $type)
{
$teamPts = getTeamPoints($team);

if($type == 'home')
{
$homem = $teamPts['home_games'];
$homew = $teamPts['home_won'];
$percent = ($homew * 100) / $homem;

$remaining = $homem - $homew;

$per = ($remaining * 100) / $homem;
$percent += $per / 2;
}
elseif($type == 'away')
{
$homem = $teamPts['away_games'];
$homew = $teamPts['away_won'];
$percent = ($homew * 100) / $homem;

$remaining = $homem - $homew ;

$per = ($remaining * 100) / $homem;
$percent += $per / 2;
}

return $percent;
}

function getpercent($hometeamid, $awayteamid)
{
$hometeampts = calculateTeamPoints($hometeamid, 'home');
$awayteampts = calculateTeamPoints($awayteamid, 'away');


$homepercent = floor(($hometeampts - $awayteampts) + 50);
$awaypercent = 100-$homepercent;


}

//demo
getpercent($hometeamid, $awayteamid);
?>

最佳答案

将如何函数 getTeamPoints 放入 IF 条件中..

if(!function_exists('getTeamPoints')){ 
function getTeamPoints()....

}

不可能不止一次声明 1 个函数!

如果您声明它超过 1 次,您必须编写不同的名称,如果您只包含该文件超过 1 次(这是错误的..),此 IF 函数存在检查将正常工作。

关于php - fatal error : Cannot redeclare getteampoints() (previously declared in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15923488/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com