So Im trying to execute a python script from php using this code
That is very bad thing to do. That is very hacky and unsafe solution. Keep this in mind.
With this said, you should be looking for php
system function that executes the command in console, not
There are multiple ways to transfer variables from php script to Python. You can write data to MySQL database and then read them from Python script. You can pack all the variables in JSON using php zip and json_encode functions, save the JSON to file on disk, and then read it from the same location in Python script.
The simplest way though is to do this in your
system("C:\Python27\python.exe /path/to/script.py $a $b $c")
This way the variables will be the arguments to Python script. There you ca just read them from
sys.argv array like that:
import sys a = sys.argv # Note that the first argument is , not  b = sys.argv ...
To transfer values back to PHP script I suggest the same thing - saving them to JSON on the disk and then reading and parsing this JSON in PHP script after the execution of Python script is finished.
Now, although I told you how to do that, you absolutely should not. Much better way is to write a CGI script on Python that will process the request and do the work you initially written in Python.You can read more here - https://www.linux.com/blog/configuring-apache2-run-python-scripts