Re: Again, help! can one set static Java variable in php?
| From: | Andrei Verovski | Date: | Mon, 19 May 2003 08:21:44 +0000 |
| Subject: | Re: Again, help! can one set static Java variable in php? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148140@lists.php.net to get a copy of this message | ||
Hi, Tao,
I've got your e-mail from php mailing list. I am sorry I cannot offer much for help you (I never used PHP with Java).
I think you should put $testStatic into $_SESSION, otherwise $testStatic will be destroyed as soon as php interpreter will finish parsing script where $testStatic is.
PS. My question for what purpose you are using PHP with Java?
-------------------------------------
On Friday, May 16, 2003, at 09:10 PM, Tao Ye wrote:
Hi, all, The traffic on this mailing list is so high that I'm hoping reposting will catch some eyeballs... Sorry to clog your mailbox but I really would like to get some response... I've been using both PHP and Java for a while, but just started to use the Java extension of PHP (calling Java objects/methods in PHP). So I'm using a PHP front end to access a Java library, with PHP4.2.3, J2sdk1.4.1 and Apache2. My question is, if in say, page1.php, I make a Java object, say, System, and call setProperty("problem", "true"), should I be able to get that property when I reload page1.php again, even though I'll re-create the Java object again? The code would look like: page1.php <?php $testStatic = new Java('java.lang.System'); print "test static, property problem is: " . $testStatic->getProperty("problem") . " <br>\n"; $testStatic->setProperty("problem", "true"); print "after setting prop, problem is: " . $testStatic->getProperty("problem") . "<br>\n"; ?> Since the JVM is created only once when the first java object is created (from a unique connection to the web server, I suppose), I don't think it's destroyed immediately upon finishing the php page?! Shouldn't the static variables and static methods keep its value from one execution of a php page to the next? I don't suppose JNI load the classes and unload them each time a php page is executed. However, when I did this test, the static property was not persisted. Anyone has any ideas? Ciao, Tao -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ********************************************** Best Regards --- Andrei Verovski * * Personal Home Page * http://snow.prohosting.com/guru4mac * Mac, Linux, DTP, Development, IT WEB Site *********************************************