function setting($a){ foreach($dbh->query("select * from setting where `name`='".$a."'") as $row){echo $row['main'];} }
已经证明foreach的语法没有错误
因为$dbh是外部变量,你要在function里先引入外部变量才行。
function setting($a){
global $dbh;
foreach($dbh->query("select * from setting where `name`='".$a."'") as $row){echo $row['main'];}
}
function setting($a){
global $dbh;
foreach($dbh->query("select * from setting where `name`='".$a."'") as $row){echo $row['main'];}
}