symisc / PH7

An Embedded Implementation of PHP (C Library)
http://ph7.symisc.net
Other
493 stars 68 forks source link

How to create a class with methods? #33

Closed IngwiePhoenix closed 3 years ago

IngwiePhoenix commented 3 years ago

Hey, remember me? Been quite a while.

I have started to work with V and I am looking to build a tool that needs a scripting language - and that is how i randomly found ph7 again. Now, I would love to know if there is a way to create classes and methods? From what I remember, namespaces were never really implemented... So I am not even gonna ask how to add methods to namespaces just yet :)

Kind regards, Ingwie

symisc commented 3 years ago

Creating classes and methods from your C code is not implemented in PH7. Only standard functions via FFI can be registered from the outside environment. A simple workaround, is to create the classes and methods in PHP and call the C functions from these methods.