Env env = null;
ScriptContext cxt = this.getContext();
try {
ReadStream reader = com.caucho.vfs.StringReader.open(script);
reader.setEncoding("utf-8");
QuercusProgram program = QuercusParser
.parse(_quercus, null, reader);
Writer writer = cxt.getWriter();
WriteStream out;
if (writer != null) {
ReaderWriterStream s = new ReaderWriterStream(null, writer);
WriteStream os = new WriteStream(s);
os.setNewlineString("\n");
try {
os.setEncoding("utf-8");
} catch (Exception e) {
e.printStackTrace();
}
out = os;
} else {
out = new NullWriteStream();
System.out.println("NullWriteStream");
}
QuercusPage page = new InterpretedPage(program);
env = new Env(_quercus, page, out, null, null);
env.setScriptContext(cxt);
// php/214c
env.start();
Object result = null;
try {
Value value = program.execute(env);
if (value != null)
result = value.toJavaObject();
} catch (QuercusExitException e) {
e.printStackTrace();