php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76197 White space not returned by substr
Submitted: 2018-04-08 16:03 UTC Modified: 2018-04-09 01:59 UTC
From: laurent dot couraud at c2n dot upsaclay dot fr Assigned:
Status: Not a bug Package: Strings related
PHP Version: 7.2.4 OS: Windows
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: laurent dot couraud at c2n dot upsaclay dot fr
New email:
PHP Version: OS:

 

 [2018-04-08 16:03 UTC] laurent dot couraud at c2n dot upsaclay dot fr
Description:
------------
all string related function i did test (substr, mb_substr, iconv_substr) return a empty string when the result should be one space character.

Test script:
---------------
// Source code saved in UTF-8 encoding.
$string = 'a b';
$c1 = substr($string, 1, 1);
$c2 = mb_substr($string, 1, 1);
$c3 = iconv_substr($string, 1, 1);
// then we obtain:
// $c1 == $c2 == $c3 == ""
// instead of 
// $c1 == $c2 == $c3 == " "



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-08 16:07 UTC] peehaa@php.net
-Status: Open +Status: Feedback
 [2018-04-08 16:07 UTC] peehaa@php.net
How did you test this behavior? As I get the expected result:

https://3v4l.org/RQ8EM

<?php

$string = 'a b';
$c1 = substr($string, 1, 1);
$c2 = mb_substr($string, 1, 1);
$c3 = iconv_substr($string, 1, 1);

var_dump($c1, $c2, $c3);
 [2018-04-08 18:22 UTC] laurent dot couraud at c2n dot upsaclay dot fr
Oops! Good point. this is not a bug in PHP but in xdebug.
Sorry for the noise.
 [2018-04-09 01:59 UTC] aharvey@php.net
-Status: Feedback +Status: Not a bug
 [2018-04-09 01:59 UTC] aharvey@php.net
Closing, given the last comment.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC