如何在php扩展中返回$ this?

时间:2012-03-16 13:28:52

标签: php c++ php-extension

例如Dataset对象的此方法返回NULL,如何让它返回$this

PHP_METHOD(TSet, nextLine)
{
    TSet *MySet;
    tset_object *obj = (tset_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
    MySet = obj->DataSet;
    if (MySet != NULL) {
        MySet->nextLine();
    }
    RETURN_NULL();
}

尝试

zval *object = getThis();
RETURN_ZVAL(object,false,false);

给了我segfault
而且还要确定这个

RETURN_ZVAL(getThis(),false,false);

结果相同

1 个答案:

答案 0 :(得分:2)

RETURN_ZVAL(getThis(),1,0);

答案是否正确,但不确定原因。http://www.snailinaturtleneck.com/blog/2011/08/11/php-extensions-made-eldrich-classes/#comment-466980122

获得