logo
JSR 223 describes a special way to pass data to the executed scripts, the context, here is a Java program that passes a StringBuffer to a PHP script which in turn adds a String to the buffer:
ScriptContext ctx = eng.getContext();
StringBuffer sb = new StringBuffer();
sb.append("before Script\n");
ctx.setAttribute("buffer", sb, ScriptContext.ENGINE_SCOPE);
$ctx = $turpenv->getScriptContext();
$buffer = $ctx->getAttribute(
                    '(Ljava/lang/String;)Ljava/lang/Object;', 
                    'buffer'
                );
$buffer->append(
            '(Ljava/lang/String;)Ljava/lang/StringBuffer;', 
            'Script Value'
        );

see: ContextSample.java

Comments

Add Comment

name:
email:
homepage:
comment:
Please enter the following code into the "verify" field below:
Verify: