用户类如下:class User {
//用户id
public $uId;
//用户名
public $userName;
//属性访问器
public function __get($name) {
return $this->$name;
} public function __set($name, $value) {
$this->$name=$value;
} //查询单个用户
function checkUser($name){
ConnectionDB::connectDB();
$sql="select * from users where userNamw='".$name."'";
$resource=mysql_query($sql);
$object=mysql_fetch_object($resource); return $object;
}欢迎页面如下:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>welcome</title>
</head>
<body>
<?php
// require("DAO/OperateDB.php");
require("Model/User.php");
$name=$_POST["username"];
$pwd=$_POST["pwd"]; $users=new User();
$user=$users->checkUser($name);
echo "用户名:".$user->userName."密码:".$user->passWord;
?>
</body>
</html>提交页面后,在欢迎页面报错,信息是:Fatal error: Cannot redeclare class User in D:\PHP_Project\CRM\Model\User.php on line 12
请问高人,这个问题怎么解决啊?
//用户id
public $uId;
//用户名
public $userName;
//属性访问器
public function __get($name) {
return $this->$name;
} public function __set($name, $value) {
$this->$name=$value;
} //查询单个用户
function checkUser($name){
ConnectionDB::connectDB();
$sql="select * from users where userNamw='".$name."'";
$resource=mysql_query($sql);
$object=mysql_fetch_object($resource); return $object;
}欢迎页面如下:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>welcome</title>
</head>
<body>
<?php
// require("DAO/OperateDB.php");
require("Model/User.php");
$name=$_POST["username"];
$pwd=$_POST["pwd"]; $users=new User();
$user=$users->checkUser($name);
echo "用户名:".$user->userName."密码:".$user->passWord;
?>
</body>
</html>提交页面后,在欢迎页面报错,信息是:Fatal error: Cannot redeclare class User in D:\PHP_Project\CRM\Model\User.php on line 12
请问高人,这个问题怎么解决啊?
改为require_once("Model/User.php");看看.
$users=new Userd();
类属性一般用私有的