PHP - mb_internal_encoding
Trieda
Metóda - mb_internal_encoding
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
To work with strings, it is important for PHP to know our encoding. We will usually (actually everytime) use UTF8. The advantage of Unicode (i.e. UTF encoding) is that we do not have to worry if the user inserts Czech, Cyrillic or something else. It is all always shown correctly. On the other hand, the disadvantage is that special characters (for example Cyrillic characters) are saved as more characters in the string. They do not take 1 byte as other characters but they are actually e.g. 2 letters (we can imagine the caron and the c letter for a character of č). We talk about so-called multi-byte characters.
We set UTF encoding via the function mb_internal_encoding().
Procedurálne
- function mb_internal_encoding (string $encoding = mb_internal_encoding()) : mixed
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $encoding | string | mb_internal_encoding() | The required encoding. |
Mávratovej hodnoty
Vracia: mixed
The function returns TRUE if the encoding has been set successfully, FALSE otherwise.
Príklady
<?php
mb_internal_encoding("UTF-8");
