Home >Backend Development >PHP Tutorial >PHP 调用对象方法问题

PHP 调用对象方法问题

WBOY
WBOYOriginal
2016-06-06 20:30:381194browse

Call to a member function get_type() on string in

<code>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);




    }
</code>

回复内容:

Call to a member function get_type() on string in

<code>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);




    }
</code>

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn