1:1 call PHP from Python

前端 未结 2 916
悲&欢浪女
悲&欢浪女 2021-01-28 06:26

We\'re using Splunk (A tool to analyse machine data like log files) and have an application in PHP. For some data we need to do a call to our application in php (CLI-based). Unf

2条回答
  •  旧巷少年郎
    2021-01-28 06:35

    Using subprocess.call:

    import sys, subprocess
    sys.exit(subprocess.call(['php', sys.argv[0].replace('.py', '.php')] + sys.argv[1:]))
    

    Edit: Made Python script return the value the PHP script returned.

提交回复
热议问题