Best feature to capitulate headers?

Should I use mb_convert_casewith MB_CASE_TITLEor ucwords? Or something different? What will be the differences?

+3
source share
2 answers

It depends.

mb_convert_case()is multibyte. ucwords()no.

mb_convert_case()requires an extension that is not always available. ucwords()always available.

So, if your application uses only single-byte encodings, then it ucwords()will give you better portability.

But if your application may need to handle multibyte encodings, then it ucwords()will fail.

+2
source
function uc_words($string){
return mb_convert_case($string, MB_CASE_TITLE, "UTF-8");
}

MB , , ASCII, ucwords ASCII.

ucwords "moj ลกal", "Moj ลกal", , "Moj ล al"... .

+2

Source: https://habr.com/ru/post/1782024/


All Articles