问题
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