How can one determine the number of bytes a character consists of in PHP, especially when working with different character encodings?

When working with different character encodings in PHP, it can be challenging to determine the number of bytes a character consists of. One way to solve this is by using the `mb_strlen()` function in PHP, which can be used to calculate the number of bytes in a character based on the specified encoding. By passing the character and the encoding as parameters to the `mb_strlen()` function, you can accurately determine the number of bytes the character occupies.

$character = "汉";
$encoding = "UTF-8";
$bytes = mb_strlen($character, $encoding);
echo "Number of bytes for character '$character' in encoding '$encoding': $bytes";