0

索引.php

<?
include "controller.php"
?>

控制器.php

<?
include "class/clientclass.php";
?>

类/clientclass.php

<?
include "configuration.php";
include "class/database.php";
$db=new Database();
?>

配置.php

<?php
class myConfig {
    public $host = 'localhost';
    public $user = 'root';
    public $password = 'root';
    public $db = 'dojo';

} ?>

类/数据库.php

<?
    class Database extends myConfig {

        function Database()
        {

                mysql_connect($this->host,$this->user,$this->password);
                mysql_select_db($this->db);

        }
    }
?>

现在我得到的错误是

Fatal error: Cannot redeclare class myConfig in /var/www/dojo/configuration.php on line 2

有什么建议吗?

4

2 回答 2

0

我认为将类名更改为 myconfig 以外的名称就可以了。在您的代码中的某些地方有一个名为 myConfig 的类。

于 2012-11-26T09:49:34.353 回答
0
<?php
namespace Config;
class myConfig {
    public $host = 'localhost';
    public $user = 'root';
    public $password = 'root';
    public $db = 'test';

} 

试试这个。

于 2012-11-26T09:56:45.210 回答