This function checks whether a string is valid UTF-8. You can ensure that the string you operate is a valid UTF-8 string. preg_match fails on strings containing invalid UTF-8 byte sequences. It does not reject character codes above U+10FFFF represented by 4 or more octets.
Source code viewer
// The string validates. } else { // The string doesn't validate. }Programming Language: PHP