# Difference between ucfirst() & Str::ucfirst()

**URL:** <https://forum.getkirby.com/t/difference-between-ucfirst-str-ucfirst/30966>\
**Category:** Questions\
**Tags:** v4\
**Created:** [March 1, 2024, 10:33am UTC](https://forum.getkirby.com/t/difference-between-ucfirst-str-ucfirst/30966 "2024-03-01T10:33:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jerome/32/14546_2.png) [@Jerome](https://forum.getkirby.com/u/Jerome)\
**Post date:** [March 1, 2024, 10:33am UTC](https://forum.getkirby.com/t/difference-between-ucfirst-str-ucfirst/30966/1 "2024-03-01T10:33:42Z")

</div>

Hello!  
I’m new to Kirby since 2 months, but already love it! I came from modx and webflow, and beginner in php.  
My question: why the php ucfirst() and the kirby Str::ucfirst() give not the same result?

```auto
<?= ucfirst('youHOU') ?> // YouHOU

```

it’s what I want and I think the normal result. But the Kirby method give

```auto
<?= Str::ucfirst('youHOU') ?> // Youhou

```

Is it normal?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 1, 2024, 11:21am UTC](https://forum.getkirby.com/t/difference-between-ucfirst-str-ucfirst/30966/2 "2024-03-01T11:21:28Z")

</div>

> [@Jerome](#):
>
> ucfirst

That’s because `Str::ucfirst()` lowercases all but the first letter. also, it applies the utf8 safe versions `mb_strtoupper($string ?? '', 'UTF-8');` and its lowercase equivalent the to uppercase/lowser those string parts.

---

<div class="post-metadata">

**Author:** ![Jerome](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jerome/32/14546_2.png) [@Jerome](https://forum.getkirby.com/u/Jerome)\
**Post date:** [March 1, 2024, 11:42am UTC](https://forum.getkirby.com/t/difference-between-ucfirst-str-ucfirst/30966/3 "2024-03-01T11:42:25Z")

</div>

OK so `Str::ucfirst()` is not only a UTF-8 safe version of `ucfirst()` as explain in Kirby doc, it has other goal.  
I can’t use `Str::ucfirst()` for a text field where I want a sentence case and let other letters as it was entry.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 1, 2024, 1:14pm UTC](https://forum.getkirby.com/t/difference-between-ucfirst-str-ucfirst/30966/4 "2024-03-01T13:14:38Z")

</div>

> [@Jerome](#):
>
> I can’t use `Str::ucfirst()` for a text field where I want a sentence case and let other letters as it was entry.

Exactly.

If in doubt what a method does, you can jump to the source code easily from the documentation.

E.g. on the page [Str::ucfirst() | Kirby CMS](https://getkirby.com/docs/reference/objects/toolkit/str/ucfirst) at the top of the page there is a link to the class method:

 ![Bildschirmfoto 2024-03-01 um 14.16.08](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/6/631fe94c675742f0fa5882f4b9e28ec43821308c.png)

That leads you right to the source code:

 ![Bildschirmfoto 2024-03-01 um 14.16.53](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/8/862ba0f9b6acfda6c7cf78c1d9978d40a9cdab96.png)

Then from there you can jump to the methods used within that method.
