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