Use PHP to encode rich text (html) to a single string
Member Chris pointed out an issue for my question where passing strings via exec() ne开发者_JAVA百科ed special treatment to avoid spaces.
<?php
{
$ID = $_POST["ID"];
$RICHTEXT = $_POST["RICHTEXT"];
exec ("/usr/local/bin/php /home/admin/folder1/TESTS/process_it.php $ID $RICHTEXT >/dev/null &");
}
?>
Assuming $RICHTEXT is a page of html, how can $RICHTEXT be encoded to a single string that will work with exec()?
I have tried to replace all the white spaces with and it fails. I have also applied htmlentities and it fails. Any ideas?
You probably want to use escapeshellarg()
Something like:
exec (sprintf("/usr/local/bin/php /home/admin/folder1/TESTS/process_it.php %s %s >/dev/null &", escapeshellarg($ID), escapeshellarg($RICHTEXT)));
精彩评论