Yes, you can mix C into C++ within PHP-CPP, however it is not a good approach for beginners because you have to understand the related API's for both.
For those up to the task, you will need to include the appropriate header files from PHP as if you were writing a standard C extension, such as
#include <php.h>
#include <php_globals.h>
#include <php_main.h>
#include <php_network.h>
// etc
You will also need to modify the Makefile for your PHP-CPP project and add the accurate include dirs for your PHP source location, for me its
COMPILER_FLAGS = -I/usr/local/include/php -I/usr/local/include/php/main ... etc ... -Wall -c -O2 -std=c++11 -fpic -o
Add standard PHP/ZEND API C code into your PHP-CPP functions/classes
Php::Value example(Php::Parameters ¶ms)
{
zval myval;
zend_string *hello, *world;
hello = zend_string_init("hello", strlen("hello"), 0);
/* Stores the string into the zval */
ZVAL_STR(&myval, hello);
/* Reads the C string, from the zend_string from the zval */
php_printf("The string is %s", Z_STRVAL(myval));
world = zend_string_init("world", strlen("world"), 0);
/* Changes the zend_string into myval : replaces it by another one */
Z_STR(myval) = world;
zend_string_release(hello);
zend_string_release(world);
return Php::Value(Z_STRVAL(myval));
}