Bug #80623 [Opn->Nab]: substring doesn't work with §,µ and £ even on online sandbox

From: Date: Thu, 14 Jan 2021 14:35:29 +0000
Subject: Bug #80623 [Opn->Nab]: substring doesn't work with §,µ and £ even on online sandbox
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231562@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 Updated by: sjon@php.net Reported by: albu dot consult at gmail dot com Summary: substring doesn't work with §,µ and £ even on online sandbox -Status: Open +Status: Not a bug Type: Bug Package: Unknown/Other Function Operating System: window PHP Version: 8.0.1 Block user comment: N Private report: N New Comment: see comment from derick Previous Comments: ------------------------------------------------------------------------ [2021-01-14 14:22:38] albu dot consult at gmail dot com typo ------------------------------------------------------------------------ [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

« previous php.bugs (#231562) next »