Home >Backend Development >PHP Tutorial >Java calls PHP example

Java calls PHP example

WBOY
WBOYOriginal
2016-07-29 09:01:021132browse

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教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn