简体   繁体   English

如何使PHP库在Java环境中工作?

[英]How to make a PHP library work in java environment?

i have a php library which is in php. 我有一个在php中的php库。 can i have this lib to work in java environment like calling the functionalists of the lib to work exactly like a java lib? 我可以让这个lib在Java环境中工作,例如调用该lib的功能主义者来像Java lib一样工作吗?

Regards Tony 问候托尼

Short answer: No 简短答案:否

Long answer: No, you can't... They are two completely different languages. 长答案:不,您不能...它们是两种完全不同的语言。

Java runs on the JRE as a platform. Java在JRE作为平台上运行。 The PHP interpreter run natively on the OS on which it runs. PHP解释器在其运行的操作系统上本地运行。

The best you could do is run PHP as a system process passing the PHP file you want to run as an argument, and capture that process' output. 最好的办法是将PHP作为系统进程运行,将要运行的PHP文件作为参数传递,并捕获该进程的输出。 (ie: run "/path/to/php myfile.php", and read the output). (即:运行“ / path / to / php myfile.php”,并读取输出)。

However, I should warn you that this is a horribe idea, and you should really re-think what you're doing. 但是,我应该警告您这是一个恐怖的主意,您应该重新考虑自己在做什么。 You java code will loose it's portability completely, as well as become awfully designed. 您的Java代码将完全失去它的可移植性,并且变得糟糕透顶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM