-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
42 lines (32 loc) · 898 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
include_once("./javaBridge/Java.inc");
try {
/* invoke java.lang.System.getProperties() */
$props = java("java.lang.System")->getProperties();
/* convert the result object into a PHP array */
$array = java_values($props);
foreach ($array as $k => $v) {
echo "$k=>$v";
echo "<br>\n";
}
echo "<hr>\n";
/* create a PHP class which implements the Java toString() method */
class MyClass
{
function toString()
{
return "hello PHP from Java!";
}
}
/* create a Java object from the PHP object */
$javaObject = java_closure(new MyClass());
echo "PHP says that Java says: ";
echo $javaObject;
echo "<hr>\n";
echo java("php.java.bridge.Util")->VERSION;
echo "<hr>\n";
} catch (JavaException $ex) {
echo "An exception occured: ";
echo $ex;
echo "<hr>\n";
}