escapeshellarg()只是用来转义shell命令的部分参数

escapeshellarg()的说明是这里

原来以为这个函数可以用来把一整条shell命令转义像这样:

$sh = 'mysql -uroot -proot -Dtest < /var/www/test.com/sql/user (1).sql';
shell_exec(escapeshellarg($sh));

 

一试就出错了。。。。

QQ截图20160322215218

仔细看了下文档才知道应该用来转义部分参数

shell_exec('mysql -uroot -proot -Dtest < ' . escapeshellarg('/var/www/test.com/sql/user (1).sql'));

问我以前为什么没出错?因为我以前是改写人家的代码,然后文档没看仔细猜着是那么个意思。。。

posted @ 2016-03-22 21:57  物理挂了  阅读(3174)  评论(0编辑  收藏  举报