如何将 zval* 转换为对象?
我有:
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=.. 的位置)
I have:
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){...}
I to solve this. I have error:
error: cannot convert ‘Car2*’ to ‘zval*’ in initialization
/home/vehicles.cc:191: error: conversion from ‘zend_class_entry*’ to non-scalar type ‘zend_class_entry’ requested `(the errors are at the point where i intialize obj11 and at ce2=..)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 API Convert_to_object_ex(value) 将 zval 转换为对象。这里,value 的类型是 **zval。
-高拉夫
Use the API convert_to_object_ex(value) to convert zval to object. Here, value is of type **zval.
-Gaurav