# Declaring php-class static member functions from within C/C++

- Thread: https://externals.io/message/22509
- Original archive: https://news-web.php.net/php.internals/22509
- Started by an.dromeda@btconnect.com on 2006-03-17T20:00:57+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22509 — an.dromeda@btconnect.com — 2006-03-17T20:00:57+00:00

URL: https://externals.io/message/22509#22509

If I define/declare php class methods via:

INIT_CLASS_ENTRY(ce, phpclassname, myclassmethods);

where myclassmethods is defined as eg:

function_entry myclass::myclassmethods[]
  = {
    PHP_ME(myclass, __construct,   arginfo_Guid__construct, ZEND_ACC_PUBLIC)
    PHP_ME(myclass, getValue, NULL, ZEND_ACC_PUBLIC)
    };

then getValue is a member function of an instantiated object,

Unsurprisingly, attempting to call myclass::getValue() therefore generates a:

"Non-static method myclass::getValue() cannot be called statically" error,
even where no dependency on the object (via getThis()) is required.

How then can I inform zend/php of my intent to supply a static member 
function, such that I can call for example myclass::somestaticfunc()

I can clearly create global functions, viz: myclass_somestaticfunc() but these
would all apparently need to be declared in the module function entry.

A neater solution would be to declare static member functions pertinent to the 
class, either by flagging them as static, or suppling a second function_entry 
to a 'static member functions *' in class_entry.

Php clearly tolerates static member functions in its own php-defined classes.

Is there a declaration mechanism available to declare them from within C/C++?

Cheers,

Andrew.

---

## #22510 — l0t3k — 2006-03-17T20:03:05+00:00

URL: https://externals.io/message/22509#22510 · In reply to: #22509

> How then can I inform zend/php of my intent to supply a static member
> function, such that I can call for example myclass::somestaticfunc()

 PHP_ME(myclass, getValue, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )

---

## #22511 — l0t3k — 2006-03-17T20:04:56+00:00

URL: https://externals.io/message/22509#22511 · In reply to: #22509

> How then can I inform zend/php of my intent to supply a static member
> function, such that I can call for example myclass::somestaticfunc()

 PHP_ME(myclass, getValue, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
