当前位置:Gxlcms > PHP教程 > PHP调用对象方法问题

PHP调用对象方法问题

时间:2021-07-01 10:21:17 帮助过:18人阅读

Call to a member function get_type() on string in

public function process($aData, &$aResult, $aConfig)
{
    var_dump($this->cart_object_apps);die;//数组里面是3个对象

    foreach ($this->cart_object_apps as $key => $object) 
    {
        $type_name = $object->get_type();//为什么调用此方法会包上述错误

        //$aResult['object'][$type_name] = $object->getAll(true,$aData);




    }

回复内容:

Call to a member function get_type() on string in

public function process($aData, &$aResult, $aConfig)
{
    var_dump($this->cart_object_apps);die;//数组里面是3个对象

    foreach ($this->cart_object_apps as $key => $object) 
    {
        $type_name = $object->get_type();//为什么调用此方法会包上述错误

        //$aResult['object'][$type_name] = $object->getAll(true,$aData);




    }

说明这个$object没有get_type方法。
我猜你是想调用gettype来获取类型吧?请参考这里:http://php.com/manual/zh/function.gettype.php

人气教程排行