How can regex patterns be properly used in PHP to avoid syntax errors?

When using regex patterns in PHP, it is important to properly escape special characters to avoid syntax errors. This can be done by using the `preg_quote()` function to escape any characters that have special meaning in regex. By doing this, you can ensure that your regex patterns are interpreted correctly and do not cause any syntax errors.

$pattern = '/^' . preg_quote($input, '/') . '$/';