??????????????????????????? test ????У???????????????????
????1. cpp.html
<!DOCTYPE html>
<html>
<head>
<title>C++????</title>
</head>
<body>
<form method="post" action="cpp.php">
<div>
<p>?????????????????</p>
<input type="text" name="arr" size="20" />
<input type="submit" value="???" />
</div>
</form>
</body>
</html>
????2. cpp.php
<?php
$arr = $_POST['arr'];
if(empty($arr)){
echo "You didn't enter any arguments.";
}
else{
$command = " test " . escapeshellcmd($arr);
$return = passthru($command);
}
?>
??????????? test.cpp ????????????к???????? test.exe ???????????????????test??????£?
#include <iostream>
#include <stdio.h>
using namespace std;
int main(int argc?? char* argv[])
{
cout<<endl<<"You passed "<<argc-1<<" arguement"<<(argc-1==1?"":"s")<<"."<< endl;
cout<<(argc-1==1?"This":"These")<<"arguement"<<(argc-1==1?"":"s")<<" "<<(argc-1==1?"is":"are")<<":"<< endl << endl;
for (int i = 1; i<argc;i++)
cout<<argv[i]<<endl;
return 0;
}