php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1386 Substr & chr(0)
Submitted: 1999-05-07 09:38 UTC Modified: 1999-05-12 08:39 UTC
From: lemming at k332 dot feld dot cvut dot cz Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.7 OS: Linux 2.x
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: lemming at k332 dot feld dot cvut dot cz
New email:
PHP Version: OS:

 

 [1999-05-07 09:38 UTC] lemming at k332 dot feld dot cvut dot cz
substr does not correctly return substrings of strings containing
null characters. Following code should print:
1
1
but it prints:
1
0

<?
  echo strlen(substr(chr(65).chr(65),0,1))."\n";
  echo strlen(substr(chr(0).chr(0),0,1))."\n";
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-05-12 08:39 UTC] rasmus at cvs dot php dot net
Fixed.  See http://cvs.php.net/cvsweb.cgi/functions/string.c
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Oct 12 22:00:01 2026 UTC