Execute PHP code in Python

0 votes
I have to run a php script to get an image from Python. I am unable to translate it into python so is there any way to run php script, with few parameters, which returns a image, in python?
Dec 10, 2018 in Python by ana1504.k
• 7,870 points
1,906 views

1 answer to this question.

0 votes
Try the following Code:

import subprocess

# if the script don't need output.
subprocess.call("php /path/to/your/script.php")

# if you want output
proc = subprocess.Popen("php /path/to/your/script.php", shell=True, stdout=subprocess.PIPE)
script_response = proc.stdout.read()
answered Dec 10, 2018 by SDeb
• 13,180 points

Related Questions In Python

+1 vote
2 answers

Does 'finally' always execute in Python?

The "finally" executes almost everytime. But there ...READ MORE

answered Aug 31, 2018 in Python by Omkar
• 67,660 points
618 views
0 votes
1 answer

How to Convert usual text to executable machine code in python

what you are looking for is a ...READ MORE

answered Oct 1, 2018 in Python by Priyaj
• 56,920 points
711 views
0 votes
1 answer

How to correctly return an a dictionary as an output in zappier code using python?

David here, from the Zapier Platform team. ...READ MORE

answered Dec 3, 2018 in Python by charlie_brown
• 7,720 points
136 views
0 votes
1 answer

How can I import tensorflow libraries in my Python code?

You are doing it wrong as tf is not ...READ MORE

answered Dec 31, 2018 in Python by charlie_brown
• 7,720 points
582 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 337 views
0 votes
1 answer

Embed R code in python

You can try this : from rpy import ...READ MORE

answered Feb 11 in Python by SDeb
• 13,180 points
25 views
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,180 points
301 views