php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9120 unexpected behavior of chop(), ltrim(), rtrim(), and trim()
Submitted: 2001-02-05 16:51 UTC Modified: 2001-03-20 05:54 UTC
From: artymiak at safenet dot pl Assigned:
Status: Closed Package: Strings related
PHP Version: 4.0.3pl1 OS: OpenBSD 2.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: artymiak at safenet dot pl
New email:
PHP Version: OS:

 

 [2001-02-05 16:51 UTC] artymiak at safenet dot pl
chop(), trim(), ltrim(), and rtrim() do not remove \v, \r, or \n.

# chop();

echo "<p><pre>                chop()";
echo "<br>                ------------------<br>";
$x = "     ab cd ef     \v\r\n" ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = chop($x);
echo strlen($y) . " characters: |" . $y . "|</pre></p>";

# ltrim();

echo "<p><pre>                ltrim()";
echo "<br>                ------------------<br>";
$x = "\v\r\n     ab cd ef     " ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = ltrim($x);
echo strlen($y) . " characters: |" . $y . "|</pre></p>";

# rtrim();

echo "<p><pre>                rtrim()";
echo "<br>                ------------------<br>";
$x = "     ab cd ef     \v\r\n" ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = rtrim($x);
echo strlen($y) . " characters: |" . $y . "|</pre></p>";

#
# trim();

echo "<p><pre>                trim()";
echo "<br>                ------------------<br>";
$x = "  \v\r\n   ab cd ef  \v\r\n   " ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = trim($x);
echo " " . strlen($y) . " characters: |" . $y . "|</pre></p>";

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-20 05:54 UTC] stas@php.net
Works for me perfectly - except that \v is not recognized by
PHP. Who needs it anyway?.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC