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.
Asked
Active
Viewed 1,209 times
1 Answers
-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.
-
i believe this question should be marke as a dup of the one you linked – WhatsThePoint Apr 12 '17 at 07:30
-