我有:
PHP_METHOD(Car, cls_ref)
{
Car *car;
//Car2 *obj11;
Car2 *car2;
zval* obj11;
zend_class_entry ce2 = zend_fetch_class("Car2", sizeof("Car2")-1, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj11,ce2) == FAILURE) {
RETURN_NULL();
}
car_object *obj = (car_object *)zend_object_store_get_object(
getThis() TSRMLS_CC);
/* car2_object *objj = (car2_object *)zend_object_store_get_object(
getThis() TSRMLS_CC);
car2=(objj->car2);
*/
car = obj->car;
if (car != NULL) {
//cout<<"in car 2 ref"<<endl;
//car2->reference(s);
// (car->cls_ref((Car2&)car2));
car->cls_ref((Car2&)obj11);
}
}
where void Car::cls_ref(Car2 &obj){...}
我要解决这个问题。我有错误:
错误:初始化时无法将“ Car2 *”转换为“ zval *”
/home/vehicles.cc:191:错误:请求从“ zend_class_entry *”转换为非标量类型“ zend_class_entry”(错误发生在我初始化obj11和ce2 =的位置。)
最佳答案
使用API convert_to_object_ex(value)将zval转换为对象。在此,值的类型为** zval。
-高拉夫
关于php - 如何将zval *转换为对象?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7427750/