The PHP Function UTF8_Encode
The php function utf8_encode is used to convert an ISO-8859-1 encoded string to a UTF-8 translated version of the data. For example, this code would encode the string "Cafe au lait" into a UTF-8 string and return it.
However, you should note that this function is not compatible with all character encodings. It only works on text that is encoded in ISO-8859-1 (AKA Latin-1). Passing arbitrary text to the utf8_encode function will probably cause bugs that do not produce any errors or warnings, but may lead to unexpected and undesired outcomes. It is recommended to use the mbstring extension instead, which provides multibyte string functions that handle characters in multiple different encodings and can be used to correctly encode and decode text between different encodings.
Another thing to note is that the utf8_encode does not verify its input data for the ISO-8859-1 encoding, it simply assumes that it is. This can cause problems when dealing with text that has a BOM at the beginning, since BOMs are encoded as 0x03 0x9B on big-endian architectures, and 0x9B 0x03 on little-endian architectures.
Normally you don't need to worry about encodings too much when working with PHP, because strings are binary data and almost all functions in PHP work on any encoding. But there are some exceptions, such as regular expressions, which need to be encoded in Unicode for proper operation. Therefore, it is important to know the encoding of your text so that you can pass it to the utf8_encode and other mbstring functions in an appropriate manner.