Windows – Linux – Mac OSX Guides

Howto call a python script from PHP

If you want to call a python script from PHP the quick & dirty way, then this post is for you. We will not install any thing other than standard PHP & Python, no mod_python or mod_wsgi messed up. I’m using this method most of the time for small functionality that I don’t want to spend time on building up a complete new project.

There are many way to call a Python script from a PHP file, in this post I will show you using the backtick operator, other options like popen, system, exec, etc .. I will cover later on

So suppose you have Python interpreter is working & a script that you want to call from PHP, the python script can accept one or more arguments.

Here is what I often come up with

Have fun!

Tagged with:     , , ,

Related Articles

Loading Facebook Comments ...

Post your comments

Your email address will not be published. Required fields are marked *