php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18677 Bug in trim() function
Submitted: 2002-07-31 14:13 UTC Modified: 2002-08-02 05:10 UTC
From: ghort at email dot cz Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.1.2 OS: WindowsXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ghort at email dot cz
New email:
PHP Version: OS:

 

 [2002-07-31 14:13 UTC] ghort at email dot cz
Hi!

I have perhaps found a bug in trim() function. I have following script:

 $text = nl2br($text);
 $text = trim($text)

The $text variable content ends of line (Unix "\n" or Windows "\r\n"). For example "1.line\r\n2.line\r\n3.line". But the result of the script above is "1.radek\r<br />\r\n2.radek\r<br />\r\n3.radek" instead of "1.radek<br />2.radek<br />3.radek".

It is my mistake, or bug of trim() function...?

Thanx for answer,
Ghort*

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-31 14:21 UTC] ghort at email dot cz
In HEX the result of that script is:

31 2E 6C 69 6E 65 0D 3C 62 72 20 2F 3E 0D 0A 32 2E 6C 69 6E 65 0D 3C 62 72 20 2F 3E 0D 0A 32 2E 6C 69 6E 65

I hope it's usefull ;o)
Ghort*
 [2002-07-31 17:49 UTC] kalowsky@php.net
Unable to reproduce on CVS head on Win2k, and OSX.  Upgrade to newer version and if it still fails, reopen the bug.
 [2002-08-02 05:10 UTC] hholzgra@php.net
the additional \r in front of the <br /> tag 
is fixed in 4.2.x

if you are expecting all \r\n's removed 
then you are wrong, nl2br only adds <br />
tags, original line brakes will stay for
HTML source readability, and trim() will
only remove the \r\n at the end of the
string, not within ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC