将 Python 或 Perl 与 PHP 集成
我将帮助我的朋友改进他的 phpBB 板,但我想用 Python 或 Perl 做点什么。但是这些语言可以与 PHP 集成吗?
I'm going to help my friend in a improve of his phpBB board, but I want to make somethings there in Python or Perl. But it's possible to integrate these languages with PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您始终可以从 PHP 中调用 python 或 perl 解释器!通过传递命令行参数和捕获 stdout(
exec
或passthru
是相关的 php 函数),可以实现简约的交换。但是,我认为这不是一个好主意 - 使用两个解释器而不是一个解释器会使整体运行时开销和启动时间加倍。
You can always call the python or perl interpreter from within PHP! Minimalistic interchange is possible by means of passing command line arguments and capturing stdout (
exec
orpassthru
are related php functions).However, I don't think its's a good idea - using two interpreters instead of one doubles the overall runtime overhead and startup time.
我想说,唯一合理的方法是,如果您正在制作一个单独的服务,您可以通过 Ajax 或 XML 或类似的东西与之通信。其他一切都比其价值更麻烦。
I'd say that the only reasonable way of doing that is if you are making a separate service, that you talk to via Ajax or XML or something like that. Everything else is more trouble than it's worth.
有 Perl PECL 包 将 Perl 集成到 PHP 中。
There is Perl PECL package to integrate Perl into PHP.