【问题标题】:PHP Deprecated: __autoload() is deprecated, with Coffee Cup form ProgramPHP 已弃用:__autoload() 已弃用,使用咖啡杯形式程序
【发布时间】:2022-11-29 02:05:01
【问题描述】:

我知道这个问题已被问过几次,但我似乎无法解决任何问题。

http://www.zutterdesign.com/contact_us.htm

右栏有一个使用 Coffee Cup Software webform 程序构建的表单。我可以获取要在页面上提交的表单,但不会发送到我的电子邮件。

“不推荐使用 PHP:不推荐使用 __autoload(),在 /home/zutterde/public_html/contactform22/fbapp/php/config.inc.php 第 64 行中使用 spl_autoload_register() 代替”是我在服务器上的电子邮件日志中收到的错误.如果我像错误所说的那样改变它,我的表格就会完全消失。

原始代码

function __autoload( $class_name )
{
    global $scriptpath;
    include $scriptpath . '/fbapp/php/' . strtolower( $class_name ) . '.cls.php';
}

更改代码:

function spl_autoload_register( $class_name )
{
    global $scriptpath;
    include $scriptpath . '/fbapp/php/' . strtolower( $class_name ) . '.cls.php';
}

【问题讨论】:

  • 您的更改可能不正确。你能给我们看一下原始代码,以及你用什么替换了吗?
  • 原文:"/*********** utility functions ************/ // 为类定义我们的自动加载器 function __autoload( $class_name ) { global $scriptpath;包括 $scriptpath . '/fbapp/php/' . strtolower( $class_name ) . '.cls.php'; }" to: /************ utility functions ******* *****/ // 为类定义我们的自动加载器 function __spl_autoload_register( $class_name ) { global $scriptpath;包括 $scriptpath 。 '/fbapp/php/' 。 strtolower($class_name)。 '.cls.php'; }”
  • 编辑问题并将代码放在那里。
  • 我已经这样做了。我不太了解 php,所以我不确定我需要什么。

标签: php forms


【解决方案1】:

spl_autoload_register() 不是这样工作的。通常你会创建一个函数,这将是自动加载器,然后你用spl_autoload_register() 将它注册到 __autoload 队列中。像这样:

function myOwnAutoload($class_name)
{
    global $scriptpath;
    include $scriptpath . '/fbapp/php/' . strtolower( $class_name ) . '.cls.php';
}

spl_autoload_register('myOwnAutoload');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    相关资源
    最近更新 更多