From: David at Caulkett dot com Operating system: Linux 2.4.22-1.2199.nptlsmp PHP version: 4.3.11 PHP Bug Type: Strings related Bug description: Passing a string variable results in incorrect length
Description: ------------ Actually PHP is version 4.3.10. Passing a string variable from test1 to test2 works fine. Passing the same string from test2 to test3 results in an incorrect length. The length is 30 greater than it should be. PHP seems to be padding the string with 30 spaces which is likely the length of the original INPUT statement. The problem is fixed by removing the extra spaces with the trim function. The test programs are at: http://www.reportillegals.com/test1.php http://www.reportillegals.com/test2.php http://www.reportillegals.com/test3.php The source of the programs are at: http://www.reportillegals.com/test1.txt http://www.reportillegals.com/test2.txt http://www.reportillegals.com/test3.txt Reproduce code: --------------- TEST1 CODE: <html> <body> <form method="POST" name="emailcomments" action="http://www.reportillegals.com/test2.php"> <input type="text" name="User_Email_Address" > <input type="submit" value="PHP Bug Test1 - Enter email address and remember the no. of chars"> </form> </body> </html> TEST2 CODE: <html> <body> <?php $length = strlen ( $User_Email_Address ); echo "length=" . $length; ?> <form method="POST" name="emailcomments" action="http://www.reportillegals.com/test3.php"> <input type="hidden" name="User_Email_Address" value=" <?php print $User_Email_Address;?> "> <input type="submit" value="PHP Bug Test2 - Length should be what you just entered. Just click Submit"> </form> </body> </html> TEST3 CODE: <html> <body> <?php $length = strlen ( $User_Email_Address ); echo "length=" . $length ."<br>"; echo "length is incorrect. it is whatever you entered +30" . "<br>"; $User_Email_Address = trim ($User_Email_Address); $length = strlen ( $User_Email_Address ); echo "length=" . $length ."<br>"; echo "length is now correct after using the trim function.". "<br>"; ?> </body> </html> Expected result: ---------------- The length in test2 and test3 should be the same number of characters as entered in test1. Actual result: -------------- The length is whatever was entered + 30. -- Edit bug report at http://bugs.php.net/?id=34056&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34056&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34056&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34056&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34056&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34056&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34056&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34056&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34056&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34056&r=support Expected behavior: http://bugs.php.net/fix.php?id=34056&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34056&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34056&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34056&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34056&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34056&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34056&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34056&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34056&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34056&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34056&r=mysqlcfg