php parameter with apostrophes

我与影子孤独终老i 提交于 2020-04-27 10:22:12

问题


I have string parameter with apostrophes that I need to pass it to another php page. My code is:

echo '<form name="submitForm2" action="creatDocument.php?$formulation='.$formulation.'" method="POST">
         <input type="submit" value="pass"/>
         </form>';

The $fomulation parameter contain the string with hebrew characters that came from user. if $fomulation = אבג"דה

creatDocument.php received just $fomulation = אבג . How can I fix it?


回答1:


What's happening is that the URL parser is breaking on the single quotes. Check out the URLEncode method, to encode your query string parameters.

http://us3.php.net/urlencode




回答2:


echo '<form name="submitForm2" action="creatDocument.php?$formulation='.urlencode(utf8_encode($formulation)).'" method="POST">
     <input type="submit" value="pass"/>
     </form>';


来源:https://stackoverflow.com/questions/22988281/php-parameter-with-apostrophes

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