I am trying to call a .exe
file in php with arguments
I use this to run .exe
$answer = shell_exec("calu.exe");
echo $answer."</br>";
This Shows result: Now how to pass argument like entering symbol
when i run this .exe
file from commad line it ask Enter Symbol and the Enter two Number. Enter symbol
Enter Number
I want to do same from Php and print result .
How can i do so ?
You said that Dos Calculator was a program of your own, written either in Python or in Batch.
What I would suggest then is to modify your program in order to handle command line arguments.
Some little snippets about how to handle command line arguments. This will store your first argument, casted as a number, in b
.
In Batch:
Set b=%1
In Python:
import sys
b = int(sys.argv[1]) # Index 0 is the name of your program
Then in php, you can call the your program with arguments like this:
$answer = shell_exec("calu.exe" . $first_number . " " . $second_number);
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.