Is it possible to run a PHP script using python?
Thanks in advance.
Is it possible to run a PHP script using python?
Thanks in advance.
You can look into the subprocess
class, more specifically, subprocess.call()
subprocess.call(*popenargs, **kwargs)
subprocess.call(["php", "path/to/script.php"]);
You can use the urllib2
library
import urllib2
urllib2.urlopen("http://sitename.com/script.php")
That is assuming the script is on another server.
If its on the same then the following should do it:
os.spawnl(os.P_NOWAIT, "php yourscript.php")
Using the os module.
Alternatively, as NullUser mentioned, you can use a sub process call:
import subprocess
def php(script_path):
p = subprocess.Popen(['php', script_path] )
You can use the Python OS module. You can run any script by calling
os.system('php -f file.php')
The issue would be getting return values from PHP to Python here.