|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-07 17:20 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 05:00:01 2025 UTC |
Description: ------------ Hello, run the following script and enter in the text area the value : line 1 line 2 <?php $out .= '<form action="test3.php" method="post">'; $out .= '<textarea name="body" rows="10" cols="70">'; if (isset($_POST['body'])) { $out .= $_POST['body']; $out .= '</textarea><br /><br />'."\n"; } else { $out .= '</textarea><br /><br />'."\n"; } if (isset($_POST['body2']) && !empty($_POST['body2'])) { if (strcmp($body, $body2)) { $out .= "strings are the same !"; } else { $out .= "strings are not the same !<br/>". $_POST['body']."<br/>". $_POST['body2']."<br/>"; } } else { $out .= '<input type="hidden" name="body2"'.' value="'.$_POST['body'].'">'."\n"; } $out .= '<input type="submit" name="submit" value ="record">'; $out .= "</form>"; echo $out; ?> It always shows the same thing : "strings are not the same !" . The character new line "\n" is not recorded when it is coming from a hidden tag in html form. I am using safe_mode and php 5.0.4. Nicolas Reproduce code: --------------- <?php $out .= '<form action="test3.php" method="post">'; $out .= '<textarea name="body" rows="10" cols="70">'; if (isset($_POST['body'])) { $out .= $_POST['body']; $out .= '</textarea><br /><br />'."\n"; } else { $out .= '</textarea><br /><br />'."\n"; } if (isset($_POST['body2']) && !empty($_POST['body2'])) { if (strcmp($body, $body2)) { $out .= "strings are the same !"; } else { $out .= "strings are not the same !<br/>". $_POST['body']."<br/>". $_POST['body2']."<br/>"; } } else { $out .= '<input type="hidden" name="body2"'.' value="'.$_POST['body'].'">'."\n"; } $out .= '<input type="submit" name="submit" value ="record">'; $out .= "</form>"; echo $out; ?> Expected result: ---------------- If you enter the 2 following lines in the text area : line1 line2 The result of the script always shows : strings are not the same ! line1 line2 line1 line2 Out that should show this : strings are the same !