开发者

Use PHP to encode rich text (html) to a single string

开发者 https://www.devze.com 2023-03-24 12:34 出处:网络
Member Chris pointed out an issue for my question where passing strings via exec() ne开发者_JAVA百科ed special treatment to avoid spaces.

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 &nbsp; 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)));
0

精彩评论

暂无评论...
验证码 换一张
取 消