Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use PHP functions in PHP extension

Can I use a PHP function such as explode() when creating an extension in C++?

like image 278
Mark Lalor Avatar asked Dec 09 '25 15:12

Mark Lalor


2 Answers

Here it is: PHP_FUNCTION(explode) expands to zif_explode with these parameters. That's the function you should call.

Read this for more details.

like image 98
rik Avatar answered Dec 11 '25 03:12

rik


PHP functions are usually implemented as parameter type checks followed by calling a native function, usually with the same name prefixed by php_.

For example, explode calls either php_explode or php_explode_negative_limit depending on the value of the third parameter (look at the source).

You can get the prototypes for these by including <ext/standard/php_standard.h>.

Make sure to check the implementation of the original PHP function for the preconditions on the arguments.

like image 43
aaz Avatar answered Dec 11 '25 03:12

aaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!