-2

Would like to know whats the Python function to call if I would like to write PHP script in Python. I am trying to utilise a PHP function that would take in values from a table created in python, operate on the text in PHP (using that PHP library) and throw the result back into a python table.

1 Answers1

-1

The question here: Execute php code in Python has some answers which may help you. Notably this one by Sjoerd:

import subprocess

result = subprocess.run(
    ['php', 'image.php'],    # program and arguments
    stdout=subprocess.PIPE,  # capture stdout
    check=True               # raise exception if program fails
)
print(result.stdout)         # result.stdout contains a byte-string

It should be reasonably easy to make that work for your use case. In this case rather than directly writing PHP in python you will write the php in another file and then call that with python and capture its results.

Community
  • 1
  • 1
axwr
  • 2,118
  • 1
  • 16
  • 29