|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-12-09 00:03 UTC] anthony_rutledge_101 at yahoo dot com
Description: ------------ --- From manual page: https://php.net/function.mb-substr --- Hi. Short and sweet. Would you please add what mb_substr() returns when it fails to the manual page? Thank you. I would have given you the answer, but my PHP 7.2.7 on Windows (legacy) does not have the multi-byte extension installed. I'm moving to PHP 7.4 anyway. Test script: --------------- The manual is the issue, not the function (as far as I know). Still, to save you time. :-) mb_internal_encoding("UTF-8"); $name = "Anthony"; echo $name . "<br>"; $newName = mb_substr($name, 0, 7); echo $newName . "<br>"; $badName = mb_substr($name, 0, 20); echo $badName . "<br>"; $badName = mb_substr($name, 20, 20); echo $badName . "<br>"; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 10:00:01 2025 UTC |
well, it would be the same as substr() because its the same thing just with multi-byte characters instead of the 7 bit ascii. so the rules should be: Returns the extracted part of string; or FALSE on failure, or an empty string. False output example would be subtracting more than the length of the word, and it is being used in a comparative state (ex: if(mb_substr($name, 0, 7)=="y"){ }).