Java:
package test;
public class HelloWorld {
public HelloWorld(String args){
}
public void ppp(){
System.out.println("....");
};
public void set(HelloWorld hw){
hw.ppp();
}
public static final String JAVABRIDGE_PORT = "28080";
static final php.java.bridge.JavaBridgeRunner runner = php.java.bridge.JavaBridgeRunner
.getInstance(JAVABRIDGE_PORT);
public static void main(String args[]) throws Exception {
runner.waitFor();
}
}
PHP:
<?php
require_once("/home/gt/workspace/JavaPhp/Java.inc");
use test\HelloWorld;
class abc extends HelloWorld{
function ppp(){
echo "!!!!";
}
}
$hw =new java("test.HelloWorld","str");
$hw -> set(new abc("str"));
You can see in the PHP code a php class extend Java class and the set()
method is Java's methods which let PHP class pass to the Java side.
Could it print "!!!!" not "...." ?
I know py4j could do it , wondering how PHP/Java Bridge do it?