How to run Ruby/Python scripts from inside PHP passing and receiving parameters?

后端 未结 5 1577
野性不改
野性不改 2020-12-09 00:08

I need to turn HTML into equivalent Markdown-structured text.

OBS.: Quick and clear way of doing this with PHP & Python.

As I am programming in PHP, som

5条回答
  •  孤城傲影
    2020-12-09 00:43

    In Python, have PHP pass the var as a command line argument, get it from sys.argv (the list of command line arguments passed to Python), and then have Python print the output, which PHP then echoes. Example:

    #!usr/bin/python
    import sys
    
    print "Hello ", sys.argv[1] # 2nd element, since the first is the script name
    

    PHP:

    
    

    The procedure should be basically the same in Ruby.

提交回复
热议问题