What is the best practice for encoding and storing PHP code in UTF-8 to avoid issues with regex matching?

When encoding and storing PHP code in UTF-8, it is important to ensure that the encoding is consistent throughout the entire process to avoid issues with regex matching. One way to achieve this is by setting the header to UTF-8 in your PHP file and using the mb_ functions for string manipulation to handle multibyte characters properly.

<?php
header('Content-Type: text/html; charset=UTF-8');

// Example of using mb_ functions to handle multibyte characters
$string = "こんにちは、世界!";
if (mb_ereg("こんにちは", $string)) {
    echo "Match found!";
} else {
    echo "No match found.";
}
?>