php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69340 trim($i, 0) and trim($i, '\0') is the same
Submitted: 2015-03-31 11:46 UTC Modified: 2015-03-31 12:53 UTC
From: nick dot sky dot pc at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.39 OS: Windows 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nick dot sky dot pc at gmail dot com
New email:
PHP Version: OS:

 

 [2015-03-31 11:46 UTC] nick dot sky dot pc at gmail dot com
Description:
------------
$i = 11000;

//$i = trim($i, 0);

 //or

 $i = trim($i, '\0');
        
 //is the same

 echo $i; //11

//Is there is bug? I expect is '\0' work as slash and zero, but not just zero

//PHP 5.4.32


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-31 12:04 UTC] julien at barmas dot name
Hi,

This is a normal case. 
You should use double quotes to use escaped character codes. 
'\0' is not equal to "\0".

'\0' means the string antislash zero, "\0" means ASCII NULL or chr(0)

Give a try to $i = trim($i, "\0"); or trim($i, chr(0));

Regards,
 [2015-03-31 12:53 UTC] bwoebi@php.net
-Status: Open +Status: Not a bug
 [2015-03-31 12:53 UTC] bwoebi@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Like julien already described...
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 01:00:02 2026 UTC