Passing PHP variable into a Python script not working
Question: I am trying to call a simple python script from a php script. The result I am
getting is just a single word while my actual input is a long text/sentence.
The php script should return the entire sentence; it currently outputs only
"The"

Python script

    
    
    import sys
    print sys.argv[1]
    

Php script

    
    
    $var1 = "The extra sleep will help your body wash out stress hormones.";
    $output = exec("C:\Python27\python.exe example.py $var1");
    echo $output;
    


Answer: Because command line parameters are space-delimited, you have to add some
quotes:

    
    
    $output = exec("C:\Python27\python.exe example.py \"$var1\"");
    

