note 124408 added to function.ucfirst

From: Date: Mon, 18 Nov 2019 12:59:20 +0000
Subject: note 124408 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-213143@lists.php.net to get a copy of this message
here is how mb_ucfirst should be implemented in userland <?php function mb_ucfirst(string $str, string $encoding = null): string { if ($encoding === null) { $encoding = mb_internal_encoding(); } return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $encoding); } ?> (when i wrote this comment, everybody else's attempt got it wrong for one reason or another, for example: some don't allow you to specify encoding, and some defaulted to utf-8 instead of defaulting to mb_internal_encoding() ) ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 81.166.125.50) ---- Manual Page -- http://php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/124408 Del: integrated -- https://master.php.net/note/delete/124408/integrated Del: useless -- https://master.php.net/note/delete/124408/useless Del: bad code -- https://master.php.net/note/delete/124408/bad+code Del: spam -- https://master.php.net/note/delete/124408/spam Del: non-english -- https://master.php.net/note/delete/124408/non-english Del: in docs -- https://master.php.net/note/delete/124408/in+docs Del: other reasons-- https://master.php.net/note/delete/124408 Reject -- https://master.php.net/note/reject/124408 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213143) next »