note 91455 deleted from java.examples-basic by sobak
| From: | sobak@php.net | Date: | Sun, 04 Dec 2016 07:08:32 +0000 |
| Subject: | note 91455 deleted from java.examples-basic by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207993@lists.php.net to get a copy of this message | ||
Note Submitter: anto dot justus at gmail dot com
----
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.