且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用$ _GET字符串传递换行符

更新时间:2023-11-13 22:45:34

Advice: You probably should think about putting this into a hidden field

Answer: But if you are going to put it into action as a GET parameter, then you need to urlencode the string:

<form action="this_page.php?string=<?php echo urlencode($string); ?>" method="post" name="name">

That way - any non-alphanumeric characters will be url safe (think about what might happen if $string contained a ? or a # or an = ).

PHP automatically decodes GET parameters when loading them into the $_GET array - so your newline should be preserved at that point.