PHP Extensions in C: Can you inherit a class in one extension from another separate extension?

StackOverflow https://stackoverflow.com/questions/22800190

  •  25-06-2023
  •  | 
  •  

質問

If I have two php extensions loaded and I want a class from one custom extension to inherit the class from another php extension.

Is that possible and how ?

I was trying to use:

zend_register_internal_class_ex(&ce, NULL , "OtherExtension\\Namespace\\OtherClass" TSRMLS_CC);

But I would always get error that it can't find it. Is there another way

I am kind of new to php extension programming and there are not much docs on this stuff.

Thanks

役に立ちましたか?

解決

I figured it out on my own, yes you can extend from other extensions, you have to make sure that classes in other extensions are exported with PHPAPI and that the other extension is always loaded before yours.

 extern PHPAPI zend_class_entry *class_entry_var; 

**:EDIT if using below code then using PHPAPI is not necessary

and then you would refer to it in your class with

 zend_register_internal_class_ex(&ce, NULL , "ClassName" TSRMLS_CC);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top