PHP扩展中如何获得并实例化PHP空间定义的类?

longmon
  • 313

PHP扩展中如何获得并实例化PHP空间定义的类?
我的代码是这样的

    zval *obj;
    MAKE_STD_ZVAL(obj);
    zend_class_entry *foo_ce;
    //hashtable_foreach_print(EG(class_table));

    if( zend_hash_find( EG(class_table), "foo", sizeof("foo"), (void **)&foo_ce ) == SUCCESS ){
        printf("get foo success\n");
        object_init_ex(obj, foo_ce);    
    } else {
        printf("get class failed\n");
    }
    printf("haloeffesfes");

但是执行到object_init_ex的时候报错了!GDB调试的结果是:

#0  0x0000000000925038 in zend_hash_apply_deleter (ht=0xfac750, p=0x120b980) at /root/php-5.5.38/Zend/zend_hash.c:619
#1  0x00000000009257b2 in zend_hash_reverse_apply (ht=0xfac750, apply_func=0x8fe67f <clean_non_persistent_class>) at /root/php-5.5.38/Zend/zend_hash.c:804
#2  0x00000000008fec25 in shutdown_executor () at /root/php-5.5.38/Zend/zend_execute_API.c:300
#3  0x000000000091297d in zend_deactivate () at /root/php-5.5.38/Zend/zend.c:946
#4  0x000000000088c26f in php_request_shutdown (dummy=0x0) at /root/php-5.5.38/main/main.c:1813
#5  0x00000000009bc433 in do_cli (argc=2, argv=0xfabb10) at /root/php-5.5.38/sapi/cli/php_cli.c:1177
#6  0x00000000009bcabb in main (argc=2, argv=0xfabb10) at /root/php-5.5.38/sapi/cli/php_cli.c:1378

这如何解决?

回复
阅读 1.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏