首頁  >  文章  >  後端開發  >  Java呼叫PHP 實例

Java呼叫PHP 實例

WBOY
WBOY原創
2016-07-29 09:01:021124瀏覽

Java调用PHP 实例

<code>package test;

import java.io.InputStream;
import java.io.InputStreamReader;

<span>public</span><span>class</span> Php {
    <span>public</span><span>static</span><span>void</span><span>main</span>(String args[]) throws Exception {
        ProcessBuilder pb = <span>new</span> ProcessBuilder(
                <span>"C:\\Users\\Administrator\\Desktop\\php-5.6.18-nts-Win32-VC11-x64\\php.exe"</span>,
                <span>"C:\\Users\\Administrator\\workspace\\JavaPhp\\src\\test\\test2.php"</span>);
        Process p = pb.start();
        InputStream <span>in</span> = p.getInputStream();
        InputStreamReader reader = <span>new</span> InputStreamReader(<span>in</span>);
        <span>char</span>[] buff = <span>new</span><span>char</span>[<span>1024</span>];
        reader.read(buff);
        System.<span>out</span>.println(buff);<span>//打印出!!!!!</span>
    }
}
</code>
<code><span><span><?php</span><span>echo</span><span>"!!!!!"</span><span>?></span></span></code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了Java调用PHP 实例,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn