java:`
public class Test{
public static void main(String[] args) {
if(args.length == 2) {
String type = args[0];
String value = args[1];
String md5 = "";
if("string".equals(type)) {
md5 = "string:"+value;
}else if("file".equals(type)) {
md5 ="file:"+value;
}
System.out.print(md5); //此處打印後,php可以獲取到內容
}
}
}
php:
<?php
$type= "string";
$value="hello world!";
$str="java TestDest ".$value." ".$key;
exec($str,$output,$retnruVal);
print_r($output); //此處會顯示java System.out.print出來的數據
?>