简体   繁体   English

php不能两次重新声明一个函数

[英]Php cannot redeclare a function twice

Why is php not able to declare a function more than one time?为什么php不能多次声明一个函数? I am using while loop with mySQL that contains list of IDs and I am trying to parse the ID to this function.我正在使用包含 ID 列表的 mySQL 的 while 循环,并且我正在尝试将 ID 解析为该函数。 But I get Fatal error: Cannot redeclare GetValue() (previously declared.... How do I fix this?但我收到Fatal error: Cannot redeclare GetValue() (previously declared....我该如何解决这个问题?

<?php
session_start();
ob_start();


$id = "";
$db = new PDO("mysql:host=localhost; dbname="DB";charset=utf8",'uid','');

$sqlID = "SELECT ID FROM Zip";
$stmtID = $db->query($sqlID);

$pdfArray = array();

while($dataID = $stmtID->fetch(PDO::FETCH_OBJ)){

    $id = $dataID->ID;

    $sql = "SELECT * FROM Datas WHERE ID = '$id'";
    $stmt = $db->query($sql);
    GetValue($id);
}

function GetValue($x){

//
}

?>

instead of:代替:

GetValue($x){

//
}

try:尝试:

function GetValue($x){

//
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM