该脚本尝试执行方法或访问不完整对象的属性

 坚韧稻草 发布于 2023-02-09 13:41

我收到一个错误,完整的错误是:

Fatal error: authnet_cart_process() [function.authnet-cart-process]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "AuthnetCart" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/golfetc/public_html/wp-content/plugins/sccp-2.4.0/authnet_functions.php on line 1266

我正在使用会话来存储购物车对象,并在稍后的某个时候获取它.authnetCart基本上是cart对象的类.

// Check cart in session
    if(isset($_SESSION['AUTHNET_CART'])) {
        // Get cart from session
        $authnetCart = $_SESSION['AUTHNET_CART'];
        foreach($authnetCart->getCartItems() as $item) {  // Line#1266
            if ($item->getItemId() == $subscription_details->ID ) {
                $addNewItem = false;
                break;
            }
        }
......

您可以在第1266行看到,代码不允许我访问其方法.任何帮助将受到高度赞赏.谢谢

1 个回答
  • 你需要include/ require你的类PHP 之前 session_start()一样

    include PATH_TO_CLASS . 'AuthnetClassFilename.php';
    session_start();
    
    if (isset($_SESSION['AUTHNET_CART'])) {
        //...
    }
    

    2023-02-09 13:43 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有