Bug #80623 [Nab->Opn]: substring doesn't work with §,µ and £ even on online sandbox
| From: | albu dot consult at gmail dot com | Date: | Thu, 14 Jan 2021 14:22:38 +0000 |
| Subject: | Bug #80623 [Nab->Opn]: substring doesn't work with §,µ and £ even on online sandbox | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231561@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80623&edit=1
ID: 80623
User updated by: albu dot consult at gmail dot com
Reported by: albu dot consult at gmail dot com
-Summary: substring doesn't work with §,µ and £ event on
online sandbox
+Summary: substring doesn't work with §,µ and £ even on
online sandbox
-Status: Not a bug
+Status: Open
Type: Bug
Package: Unknown/Other Function
Operating System: window
PHP Version: 8.0.1
Block user comment: N
Private report: N
New Comment:
typo
Previous Comments:
------------------------------------------------------------------------
[2021-01-14 14:22:27] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
These letters use more than one byte per character, and substr only operates on bytes. You want to
use mb_substr instead.
------------------------------------------------------------------------
[2021-01-14 14:21:01] albu dot consult at gmail dot com
Description:
------------
$test = '§abcd';
$test1 = substr($test,1);
echo $test1;
It should return "abcd" it doesnt but: "�abcd"
I tested it does same thing with §, µ, £ and perhaps other char I didn't think of.
Test script:
---------------
$test = '§abcd';
$test1 = substr($test,1);
echo $test1;
Expected result:
----------------
abcd
Actual result:
--------------
�abcd
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80623&edit=1