Issue
.php file code
<?php
$para1 = "one";
echo shell_exec("python C:/xampp/htdocs/python/test.py '$para1'");
?>
.py file code
#! C:\Users\mhammad\AppData\Local\Programs\Python\Python39\python.exe
print("Content-Type: text/html\n\r\n") #this code is for run .py file in xampp localserver.
import sys
print(sys.argv)
output of python file while running on xampp server in browser.
['C:/xampp/htdocs/python/test.py']
how do I get variable value from .php file to .py file.
Solution
This above mentioned code is working absolutely fine but the twist is that the xyz.py file is running in background on command line terminal and this print(sys.argv)
can use the variable value $para1 = "one";
in xyz.py file and print the value of that shared variable.
thanks
Answered By - Mangal Prasad Hammad Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.