-
Notifications
You must be signed in to change notification settings - Fork 341
Open
Description
Before PHP8.2, Php::eval function evaluated code without requirement of <?php starter tag.
After PHP8.2 (PHP8.3, PHP8.4) it does not work as expected.
Line 45 in 5c9a31a
| return zend_compile_string(zval_get_string(source._val), (char*)name, ZEND_COMPILE_POSITION_AT_OPEN_TAG); |
Here is the mentioned line, is there anything i can do for retrieving old behaviour?
Example code:
#include <phpcpp.h>
#include <iostream>
#include <string>
/**
* Simple function that demonstrates Php::eval
*/
Php::Value eval_test(Php::Parameters ¶ms)
{
// Execute PHP code using Php::eval
Php::Value result = Php::eval("return 'test';");
// It returns test before PHP8.3
// It returns just string like; "return 'test';" after PHP8.3
// To get it working we should use it like:
Php::Value result = Php::eval("<?php return 'test';");
// But it breaks backwards compability for my case
// Return the result
return result;
}
/**
* Extension initialization
*/
extern "C" {
PHPCPP_EXPORT void *get_module()
{
// Create extension
static Php::Extension extension("eval_test", "1.0");
// Add the eval_test function
extension.add<eval_test>("eval_test");
// Return the extension
return extension;
}
}Metadata
Metadata
Assignees
Labels
No labels