I want a way to pass input into a python script from PHP. I am using the following command but can't seem to figure out a way to pass a value to the script
$command = escapeshellcmd('/usr/custom/test.py');
$output = shell_exec($command);
for example you have a simple input like this :
<input type="text" name="name"><br>
To pass it you can simply do like this:
<?php system("python mycode.py ".$_POST["name"]); ?>
you can also use exec()
and passthru()
system("python mycode.py <arg1> <arg2>");
//or
exec("python mycode.py <arg1> <arg2>");
//or
passthru("python mycode.py <arg1> <arg2>");
have a good time !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.