php报错重定义
我的php代码运行报错:如下
Fatal error: Cannot redeclare NewConn() (previously declared in /usr/local/httpd/htdocs/yzmm/xzq/html/xzq/qbn/MysqlInterface/InitSqlConnect.php:20) in /usr/local/httpd/htdocs/yzmm/xzq/html/xzq/qbn/MysqlInterface/InitSqlConnect.php on line 18
但是感觉不是很准,下面是报错提示的文件内容,请帮忙确定一下是为什么报错,一个是声明一个是使用怎么会重定义呢?
<?php
namespace QueryResultStructEnum {
const InfoTypeResult = 0; //InfoType表查询结果
const NodeTypeResult = InfoTypeResult + 1; //NeType表查询结果,NeInstance表查询结果:int, string, int, int
};
namespace {
$con= NewConn();
if($link->connect_error)
{
die("连接失败: ".$link->connect_error);
}
else
{
}
function NewConn()
{
$host = '127.0.0.1';
$user = 'root';
$password = '123456';
$dbName='yzmm';
$con= mysqli_connect($host,$user,$password);
mysqli_select_db($con,$dbName);
return $con;
}
function CloseConn($con)
{
$con->close();
}
}
?>