Search code examples
phpphp-extensionphp4php-internals

Calling extension function in zend_eval_string


When i try use zend_eval_string (i make mini php extension), there are no extensions functions avaliable. There are also no errors reporting (if php code have fatal error program exit). What i must do to enable extension and show errors when it executes? I also found interesting value EG(no_extensions)=1; in zend_execute_API.c, but when i change this value to 0 problem not solving. I am newer of c++ and please, tell me how to solve this problem with example.

Sorry for my bad English.


Solution

  • Maybe help

    int eval_php_code(char *code) {
        int ret = 0;
    
        zend_try {
            ret = zend_eval_string(code, NULL, (char *)"" TSRMLS_CC);
        } zend_catch {
    
        } zend_end_try();
    
        return ret == FAILURE;
    }