通过php exec函数传递$ _SERVER数组 [英] pass $_SERVER array through php exec function
问题描述
可能重复:
安全执行的shell脚本;在执行前转义vars
Possible Duplicate:
Safe executing shell scripts; escaping vars before execution
我想通过php exec()
函数传递$_SERVER
数据,以便为后台进程运行另一个脚本.
传递一个简单的参数,我这样做是这样的:
I want to pass $_SERVER
data through php exec()
function to run another script for background process.
to pass a simple parameter I do it like this:
exec("/usr/bin/php -f bg.php parameter1 > /dev/null &");
但是我认为不可能直接将数组传递给该函数.所以我尝试了 serialize($_SERVER)
.但是现在有一个更大的问题.诸如引号,分号之类的字符会破坏shell命令,因此无法正常工作.
But I think it is impossible to directly pass an array to this function. So I tried serialize($_SERVER)
. but now there's a bigger problem. Characters like quotations, semicolons and many others break down the shell command and it doesn't work properly.
那么解决这个问题的解决方案是什么?
So what's the solution to solve this problem?
推荐答案
也许您正在寻找的是: http://php.net/manual/en/function.escapeshellarg.php
Maybe what you are looking for is: http://php.net/manual/en/function.escapeshellarg.php
这篇关于通过php exec函数传递$ _SERVER数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!