View Full Version : Maintaining state across multiple php call from java

11-12-2010, 08:02 AM

I'm trying to maintain state across multiple php calls from java - but failing.

By state I mean the variable / function space - see below:

QuercusEngine qe = new QuercusEngine();
qe.execute("<?php function foo() { echo 'hello foo\n'; } ?>");
qe.execute("<?php foo(); ?>");

Unfortunately on the last line I get - instead I'd like to be able to call the function foo:

Exception in thread "main" com.caucho.quercus.QuercusErrorException: eval::1: Fatal Error: 'foo' is an unknown function.
at com.caucho.quercus.env.Env.error(Env.java:6469)
at com.caucho.quercus.env.Env.error(Env.java:6355)

Any help would be appreciated.


12-23-2010, 07:48 PM
you're actually interpreting two different scripts here, thats why the second script doesn't "know" the function defined in the first one.

09-19-2011, 08:58 AM
It is a great pleasure to declare you that your article has fascinated me. You are doing a great job. Keep up the work...

the office seasons 1-6 (http://www.wholesalecheapdvd.com/The-Office-Season-1-6-DVD-Boxset-FREE-SHIPPING-272.html)
will and grace seasons 1-8 (http://www.wholesalecheapdvd.com/Will-and-Grace-Seasons-1-8-DVD-Boxset-FREE-SHIPPING-455.html)

Don Hamis
10-11-2011, 07:29 AM
A typical use of a function object is in writing callback functions. A callback in procedural languages, such as C, may be performed by using function pointers. However it can be difficult or awkward to pass a state into or out of the callback function. This restriction also inhibits more dynamic behavior of the function. A function object solves those problems since the function is really a faĆ½ade for a full object, thus it carries its own state.