note 91455 modified in java.examples-basic by felipe

From: Date: Thu, 11 Jun 2009 02:34:17 +0000
Subject: note 91455 modified in java.examples-basic by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156762@lists.php.net to get a copy of this message
php java The PHP code here is simple and straight forward. It is not OOP. But you probably got enough of that while doing the Java code. <?php java_require("F:\\wamp5\\www\\classes\\"); $obj = new Java("hello"); // Call the "sayHello()" method $output = $obj->SayHello(); echo $output.' this text in PHP '; // Displays (so this comes from the class!) // Call the "SayNumber()" method $output = $obj->SayNumber(); // Displays (so this comes from the class!) echo $output.' is a lucky number'; //Because the JVM caches everything we want reset while playing with the code. Otherwise the // a cached version of the same class file will be used rather than the new one echo " Resetting back-end to initial state\n"; // suppress the warning message from the use of reset. @java_reset(); ?> That's it. Now browse to the PHP page and you should get the results shown below. --was-- php java The PHP code here is simple and straight forward. It is not OOP. But you probably got enough of that while doing the Java code. java_require("F:\\wamp5\\www\\classes\\"); $obj = new Java("hello"); // Call the "sayHello()" method $output = $obj->SayHello(); echo $output.' this text in PHP '; // Displays (so this comes from the class!) // Call the "SayNumber()" method $output = $obj->SayNumber(); // Displays (so this comes from the class!) echo $output.' is a lucky number'; //Because the JVM caches everything we want reset while playing with the code. Otherwise the // a cached version of the same class file will be used rather than the new one echo " Resetting back-end to initial state\n"; // suppress the warning message from the use of reset. @java_reset(); ?> That's it. Now browse to the PHP page and you should get the results shown below. http://php.net/manual/en/java.examples-basic.php

« previous php.notes (#156762) next »