How can I escape quotes on a PHP system call?

蓝咒 提交于 2021-01-29 05:59:09

问题


I'm passing to perl from php using escapeshellarg

system("perl -e '" . escapeshellarg($inp) . "' >> /tmp/out");

And get unterminated quoted string from perl.

Input is: 'Single quoted terminated string\n';


回答1:


Please note that escapeshellarg adds the outer single quotes itself.

So you should leave them out:

system("perl -e " . escapeshellarg($inp) . " >> /tmp/out");
#              ^                            ^ no extra ' quotes here


来源:https://stackoverflow.com/questions/11331125/how-can-i-escape-quotes-on-a-php-system-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!