Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mention ZEND_NS_NAMED_FE macro #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Book/php7/extensions_design/php_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ Then, we gather that function symbol and add it to the ``pib_functions`` vector.
functions using the ``PHP_FE`` macro. That latter needs the PHP function name, and an argument vector which we passed
NULL for the moment.

You can register your function under a specific namespace using the `ZEND_NS_NAMED_FE` macro, this macro
takes four parameters :

* the namespace string, e.g: "Pib\\Book".
* the function name, this will be the final function name under the new namespace, for example lets call it : `f2c`.
* the function handler, from our example: `fahrenheit_to_celsius`.
* the arg info which will be covered in this chapter.

So the final `zend_function_entry` would be something like::

static const zend_function_entry pib_functions[] =
{
ZEND_NS_NAMED_FE("Pib\\Book", f2c, fahrenheit_to_celsius, NULL)
};

Note that your new function will take a new name here which will be `f2c`.

Into our *php_pib.h* header file, we should here declare our function, like the C language tells us to do so::

/* pib.h */
Expand Down