PHPverse 2025

Voting

: min(four, one)?
(Example: nine)

The Note You're Voting On

divinity76 at gmail dot com
5 years ago
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() )

<< Back to user notes page

To Top