Menu

[r608]: / branches / Release-4-3-3 / php-java-bridge / tests.php5 / session_vars.php  Maximize  Restore  History

Download this file

48 lines (40 with data), 983 Bytes

 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
43
44
45
46
#!/usr/bin/php
<?php
if (!extension_loaded('java')) {
if (!(require_once("http://127.0.0.1:8080/JavaBridge/java/Java.inc"))) {
echo "java extension not installed.";
exit(2);
}
}
$ser="vector.ser";
// load the session from the disc
if(file_exists($ser)) {
$file=fopen($ser,"r");
$id=fgets($file);
fclose($file);
try {
$v=unserialize($id);
} catch (JavaException $e) {
echo "Could not deserialize: ". $e->getCause() . "\n";
$v=null;
}
}
// either a new session or previous session destroyed
if(!$v) {
echo "creating new session\n";
$vector=new java("java.util.Vector", array(1, true, -1.345e99, "hello", new java("java.lang.Object")));
$v=array (
"test",
$vector,
new java("java.lang.String", "HelloWorld"),
3.14,
new java("java.lang.Object"));
$id=serialize($v);
$file=fopen($ser,"w");
fwrite($file, $id);
fclose($file);
} else {
echo "cont. session\n";
}
echo ($v[1]->__toString())."\n". $v[2]->__toString()."\n";
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.