【发布时间】:2016-07-27 16:27:30
【问题描述】:
这是我的 Javascript:
var url = "load.php?x="+x;
xmlhttp.open("GET", url, true);
其中 x 是一个已定义的变量。
这是我的 PHP:
$var = $_GET['x'];
echo shell_exec('./test2/test2 $var');
其中 test2 是一个包含可执行文件的文件夹,而 $var 是一个参数。这适用于我的第二个语句是
echo shell_exec('./test2/test2 param');
这显示在我的错误日志中:
terminate called after throwing an instance of 'terminate called after throwing an instance of 'std::logic_errorstd::logic_error'
what(): what(): basic_string::_S_construct NULL not validbasic_string::_S_construct NULL not valid
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
我做错了什么?
谢谢!
【问题讨论】:
-
您使用的是单引号...尝试更改为
'./test2/test2' . $var或"./test2/test2 $var"
标签: javascript php parameters xmlhttprequest system-calls