Use the chr() function and any number above 127 to create an invalid utf8 character. This may be useful if you want to test your UTF-8 validation script. See the below code as an example. It’ll print ‘UTF-8’ if the character is valid UTF-8 or nothing otherwise.
echo mb_detect_encoding(chr(128), 'UTF-8', true); |