douxiajia6104 2011-07-28 00:49
浏览 82
已采纳

Python PHP和Perl一起使用?

I was reading through Facebook's hiring now job listings and I saw this...

* Competency in Shell, PHP, Perl or Python. C is a plus

This sparked a question in my mind, is it possible to use (for example) python and PHP together?

As in... I write a function in PHP to read a MySQL database and cut the data read into raw string form.

I then use python to use this PHP function to perform operations on this data.

The part where I say "use python to use this PHP function" is this possible?

If so, how? (a small code example would be awesome)

  • 写回答

3条回答 默认 最新

  • doudichu1358 2011-07-28 01:03
    关注

    I think there are two answers.

    The simple answer to this question is to use the exec() function in your PHP scripts to execute python scripts.

    There is also the complicated answer, to either build, or use a prior attempted PHP extension PiP:

    this extensions allows the Python interpretter to be embedded inside of PHP (think of PHP as the parent language with Python as its child). This allows native Python objects to be instantiated and manipulated from within PHP. There is also initial support for accessing PHP functions and data from within the embedded Python

    I'd love to see some examples of it in use.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?