【问题标题】:When sending an email, Cannot redeclare fatal error [duplicate]发送电子邮件时,无法重新声明致命错误 [重复]
【发布时间】:2017-04-28 05:54:05
【问题描述】:

我在尝试发送电子邮件时收到以下错误。

致命错误:无法在第 31 行的 C:\xampp\htdocs\ISPSystem\mail\PHPMailerAutoload.php 中重新声明 PHPMailerAutoload()(之前在 C:\xampp\htdocs\ISPSystem\mail\PHPMailerAutoload.php:24 中声明)

【问题讨论】:

    标签: php mysql gmail


    【解决方案1】:

    你使用require_once,它只包含你的文件一次,所以这个函数不能重新声明。

    require_once 'yourfilepath/yourfile.php';
    

    所以文件链接会是这样的

    require_once . 'mail/PHPMailerAutoload.php';
    

    更多关于require_once

    http://php.net/manual/en/function.require-once.php

    或者检查函数是否退出然后调用这个函数

    if (!function_exists('PHPMailerAutoload')) {
       function PHPMailerAutoload($classname)
         {
         // your function code
         }
        }
    

    更多信息

    http://php.net/manual/en/function.function-exists.php

    【讨论】:

    • 我解决了我的问题。
    • 我的解决方案不起作用?
    • 这是由于双重重复而发生的。请再次检查您的代码。
    • 这发生了为什么我知道但是如果你使用 require_once 那么如果你包含很多时间那么它不会有问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 2014-01-13
    • 2011-07-17
    • 2010-12-29
    • 2015-08-29
    • 2012-06-18
    相关资源
    最近更新 更多