How can the code be modified to check for BIG5 encoding instead of UTF-8?

To check for BIG5 encoding instead of UTF-8, we can use the mb_detect_encoding() function with the 'BIG5' encoding option. This function will return the detected encoding of a string, allowing us to determine if it is encoded in BIG5.

$string = "Sample text encoded in BIG5";

if(mb_detect_encoding($string, 'BIG5', true) === 'BIG5') {
    echo "The string is encoded in BIG5.";
} else {
    echo "The string is not encoded in BIG5.";
}