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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 06:01:25 2019 UTC