First i need import a file from PHP_FUNCTION(), and passing to imported php file some variables from C function into userspace.
Example:
include_a_file.c
PHP_FUNCTION(include_a_php_file)
{
zval *var_to_userspace;
char *str;
str = "string send to userspace";
ZVAL_STRING(var_to_userspace, str, 0);
php_require_once("a_file.php"); // <-- how to?
}
a_file.php
<?php
print "<pre>";
vardump($var_to_userspace);
print "</pre>";
?>
Try to call zend_compile_string()
:
zval nop;
ZVAL_STRINGL(&nop, "return ;", 8, 0);
zend_compile_string(&nop, "NOP" TSRMLS_CC);
This will return you pointer to zend_op_array
struct, which will be holding Zend opcodes for your code. So you can just dump these opcodes once and create zend_op_array
struct in your program yourself.