Last active
September 11, 2016 04:37
-
-
Save anmolgkv/9b1660cce801dfecc26f77adf48b8e95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start_word = 'hello'; | |
$end_word = 'world'; | |
echo "Start word: ". $start_word . "<br />"; | |
echo "End word: ". $end_word . "<br />"; | |
echo "Running the test.py..."; | |
echo "</br>"; | |
$output = exec("python test.py ".$start_word." ".$end_word); | |
echo 'output from python script: '; | |
var_dump( json_decode($output, true)); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, json | |
print('Number of arguments: ') | |
print(len(sys.argv)) | |
print('arguments.') | |
print('Argument List:') | |
print(str(sys.argv)) | |
result = {'status' : 'Yes!'} | |
print(json.dumps(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save these files in a folder.
then go to the folder from CMD and type : php -S localhost:8001
Now in the browser open : http://localhost:8001
Also make sure that both python and php are set in the environment variable.
Leave comment if you still need any clarification.
You shoud see:
Start word: hello
End word: world
Running the test.py...
output from python script: array(1) { ["status"]=> string(4) "Yes!" }