简体   繁体   English

致命错误:无法在第3行的C:\\ xampp \\ htdocs \\ includes \\ classes \\ class.login.php中重新声明类登录名

[英]Fatal error: Cannot redeclare class Login in C:\xampp\htdocs\includes\classes\class.login.php on line 3

I'm working on a login. 我正在登录。 As the base I took PHP-Login because it provides a lot of stuff at forehand. 作为基础,我选择了PHP-Login,因为它直接提供了很多东西。 Now I'm getting this error: 现在我得到这个错误:

Fatal error: Cannot redeclare class Login in C:\xampp\htdocs\includes\classes\class.login.php on line 3

When looking at the first few lines of class.login.php I don't see any mistakes: 查看class.login.php的前几class.login.php我没有看到任何错误:

<?php
class Login {
    private $db_connection = null;
    public $errors = array();
    public $messages = array();
    public function __construct() {
        if (isset($_GET["logout"])) {
            $this->doLogout();
        }
        elseif (isset($_POST["login"])) {
            $this->dologinWithPostData();
        }
    }

If anyone sees the error, please tell me. 如果有人看到错误,请告诉我。

The error message indicates that a class of that name is already declared when this part of the code is reached. 错误消息表明,到达代码的这一部分时,已经声明了该名称的类。 This can have multiple reasons: 这可能有多个原因:

  1. You included php code that declares a class of the same name 您包括了声明同名类的php代码

  2. You included the file "class.login.php" twice using include() or require() instead of include_once() or require_once(). 您使用include()或require()而不是include_once()或require_once()两次包含了文件“ class.login.php”。 *_once() functions will make sure that contained code is only considered once (as the name suggests) to avoid such errors. * _once()函数将确保所包含的代码仅被考虑一次(顾名思义),以避免此类错误。

  3. You are using a class loader and screwed it up. 您正在使用类加载器并将其拧紧。 If this was the case my strong advice is to go without dynamic class loading. 如果是这种情况,我强烈建议不要动态加载类。 It is difficult to read and understand and adds "magic" to the behaviour of your code which in most cases is only clear to one person in the world - to you. 很难阅读和理解,并且在代码的行为中增加了“魔力”,在大多数情况下,代码行为对世界上只有一个人是清楚的。 Code should be easy to read and understand though. 但是,代码应易于阅读和理解。

I hope this helps. 我希望这有帮助。

暂无
暂无

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

相关问题 致命错误:无法在第 11 行的 D:\\xampp\\htdocs\\Test1\\tedboy\\include\\home\\header.php 中重新声明类数据 - Fatal error: Cannot redeclare class data in D:\xampp\htdocs\Test1\tedboy\include\home\header.php on line 11 致命错误:未捕获的错误:第 23 行的 Class &#39;User&#39; C:\\xampp\\htdocs\\gallery\\admin\\includes\\admin_content.php - Fatal error: Uncaught Error: Class 'User' C:\xampp\htdocs\gallery\admin\includes\admin_content.php on line 23 Symfony 2 - 致命错误:无法在第532行的C:\\ ... \\ app \\ cache \\ dev \\ classes.php中重新声明类SessionHandlerInterface - Symfony 2 - Fatal error: Cannot redeclare class SessionHandlerInterface in C:\…\app\cache\dev\classes.php on line 532 致命错误:无法在第 39 行的 C:\\xampp\\htdocs\\app\\language_helper.php 中重新声明 mb_str_split() - Fatal error: Cannot redeclare mb_str_split() in C:\xampp\htdocs\app\language_helper.php on line 39 致命错误:第17行的C:\\ xampp \\ htdocs \\ w-classes \\ class.functions.php中超过30秒的最大执行时间 - Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\w-classes\class.functions.php on line 17 提交后:PHP致命错误:在C:\\ xampp \\ htdocs \\中找不到类 - After submit: PHP Fatal error: Class not found in C:\xampp\htdocs\ PHP致命错误:在C:\\ xampp \\ htdocs \\中找不到类 - PHP Fatal error: Class not found in C:\xampp\htdocs\ PHP致命错误:在C:\\ xampp \\ htdocs \\中找不到类“线程化” - PHP Fatal error: Class 'Threaded' not found in C:\xampp\htdocs\ 致命错误:第 81 行的 C:\xampp\htdocs\web1\wp-admin\includes\class-wp-filesystem-direct.php 中超过 30 秒的最大执行时间 [暂停] - Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\web1\wp-admin\includes\class-wp-filesystem-direct.php on line 81 [on hold] 致命错误:在第633行的C:\\ xampp \\ htdocs \\ libraries \\ cms \\ application \\ cms.php中找不到类&#39;JApplicationHelper&#39; - Fatal error: Class 'JApplicationHelper' not found in C:\xampp\htdocs\libraries\cms\application\cms.php on line 633
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM