-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
  • Can you share your code please ? Commented Apr 12, 2017 at 7:34

1 Answer 1

-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.

Sign up to request clarification or add additional context in comments.

2 Comments

i believe this question should be marke as a dup of the one you linked
It does seem slightly different but i don't disagree with you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.