Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling PHP functions returns null #317

Open
ond1 opened this issue Mar 10, 2017 · 3 comments
Open

Calling PHP functions returns null #317

ond1 opened this issue Mar 10, 2017 · 3 comments

Comments

@ond1
Copy link

ond1 commented Mar 10, 2017

Hi,

I am working on a XSLT with PHP project which involves allowing the user the possibility to write their own extension function. The problem I am hitting is on the C++ side the function (i.e. userFunction) is always returning null. I am currently working from PPH-CPP-LEGACY. Any ideas what I am doing wrong.

In PHP:

// define a user space function function userFunction($param) { echo("userspace function called with no param\n"); return "user function - data"; }

In C++:

`jobject JNICALL PHP_SaxonProcessor::phpNativeCall
(JNIEnv *env, jstring funcName, jobjectArray arguments, jobjectArray arrayTypes){

const char *nativeString = SaxonProcessor::sxn_environ->env->GetStringUTFChars(funcName, NULL);

Php::Value data = Php::call(nativeString, 'something');

SaxonProcessor::sxn_environ->env->ReleaseStringUTFChars(funcName, nativeString);
if(data == NULL) {
return NULL;
} else {
return SaxonProcessor::sxn_environ->env->NewStringUTF(dataChar);
}
}`

@ond1
Copy link
Author

ond1 commented Mar 16, 2017

Update:
What I have noticed is the php function is executed but just not returning a value. As mentioned before a null is returned.

@sallyx
Copy link

sallyx commented Jun 7, 2017

I have similar problem with lambda functions. Using the example http://www.php-cpp.com/documentation/lambda-functions, lambda function is called, but in C++/PHP is returned NULL value (even If i simple give "return 1;" statement at the beginning of the lambda function).

Tested with PHP 7.0 and PHP 7.1.

Update: Tested latest version with PHP 7.2 and it works!

@pantingwen
Copy link

I have the same problem,my php version is 7.2.5. Php::Function always return null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants