Are there best practices for structuring the parameters in preg_match() to avoid errors?

When using preg_match(), it's important to properly structure the parameters to avoid errors. This includes ensuring that the regular expression pattern is enclosed in forward slashes, and that any special characters are properly escaped. Additionally, it's important to provide the subject string as the second parameter, and to capture any potential matches in an appropriate way.

$subject = "Hello, World!";
$pattern = "/Hello/";

if (preg_match($pattern, $subject, $matches)) {
    echo "Match found!";
} else {
    echo "No match found.";
}