Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling PHP from Python

Tags:

python

php

Is it possible to run a PHP script using python?

like image 959
usertest Avatar asked Sep 24 '10 04:09

usertest


2 Answers

You can look into the subprocess class, more specifically, subprocess.call()

subprocess.call(*popenargs, **kwargs)

subprocess.call(["php", "path/to/script.php"]);
like image 116
NullUserException Avatar answered Sep 25 '22 22:09

NullUserException


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.

like image 23
sheki Avatar answered Sep 25 '22 22:09

sheki